How do I create a structure side navigation that will show active parent list-item and active child list-item A bit of a background on the project. I have a features structure section, that has 2 levels: Parent features &amp; Child features.

{% set features = craft.entries.section('features').all() %}

My goal is to get an active class on the parent if the parent page is active or if it's got a child that is active and also get an active class on the child if its active.

The {% children %} tag doesn't allow for custom HTML.

I am looking to get something similar to this left navigation. But instead of anchors, each feature will be its own page.
https://craftcms.com/features/all#section-types

Thanks
After a long search and lots of trial and error, I've found the perfect solution!
This is how I created a dynamic structure navigation : parent/child (2 levels deep) with class="active" on the parent and the child &lt;li&gt;.

&lt;ul class="Navigation"&gt;

{# Get top-level entries in structure section 'features' #}
{% set parentFeatures = craft.entries.section('features').level(1) %}

{# Loop through top-level entries #}
{% for parentFeature in parentFeatures %}

    {# Check if entry has descendants/children #}
    {% if not parentFeature.hasDescendants %}

        {# List navigation item if entry has NO child entries #}
        &lt;li class="Navigation-item {% if craft.app.request.absoluteUrl == parentFeature.url %}active{% endif %}"&gt;
            &lt;a href="{{ parentFeature.getUrl }}" class="Navigation-link"&gt;{{ parentFeature.title }}&lt;/a&gt;
        &lt;/li&gt;

    {% else %}

        {# List navigation item if entry does have child entries #}
        {# Show an active class if it is active or if it contains a child that is active #}
        &lt;li class="Navigation-item Navigation-item--dropdown {% if parentFeature.slug == craft.request.getSegment(parentFeature.level) %}active{% endif %}"&gt;

            &lt;a href="{{ parentFeature.getUrl }}" class="Navigation-link"&gt;{{ parentFeature.title }}&lt;/a&gt;
            &lt;ul class="Navigation Navigation--subMenu"&gt;

                {# Get child entries of current iteration's top-level entry #}
                {% set subPages = parentFeature.getChildren() %}

                {# Loop through those 2nd-level entries #}
                {% for subPage in subPages %}

                    {# This is the place where you'd nest the next menu hierarchy !! #}

                    {# List sub-menu navigation item #}
                    &lt;li class="Navigation-item Navigation-item--subMenu {% if craft.app.request.absoluteUrl == subPage.url %}active{% endif %}"&gt;
                        &lt;a href="{{ subPage.getUrl }}" class="Navigation-link Navigation-link--subMenu"&gt;{{ subPage.title }}&lt;/a&gt;
                    &lt;/li&gt;

                {% endfor %}

            &lt;/ul&gt;
        &lt;/li&gt;
    {% endif %}
{% endfor %}

&lt;/ul&gt;




Thanks to Carlcs's old answer about this found here: https://craftcms.stackexchange.com/a/1847/6586