Skip to content

body nav:first-of-type is too restrictive for real-world use cases #15

@Arcesilas

Description

@Arcesilas

Hi,

First of all, thanks for creating Bahunya — I really like its minimal and elegant approach.
However, I’ve run into a limitation with the rule targeting the site navigation:

body nav:first-of-type { ... }

This selector assumes that the first <nav> element in the document is the main site navigation.
Unfortunately, this becomes problematic as soon as you introduce other <nav> elements elsewhere — for example, pagination, article navigation, or table of contents.

Because :first-of-type applies within each parent, not globally within the document, every first <nav> inside a container (e.g. <main>, <aside>) also matches this rule.
As a result, styling leaks to other navs unintentionally.

💡 Suggested improvement

It would be more robust to target the main navigation explicitly, for example: header > nav.

This keeps the classless nature of Bahunya but avoids false positives.

Thanks again for this lovely project — it’s small details like this that can make classless CSS even more versatile!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions