Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it preferable to select class or <nav> element? [closed]

Tags:

html

css

nav

I have been told on several occasions not to select elements such as <nav> & <body> and to instead use the class selectors. For example, "the <nav> tag is not for display/styling purposes but it is to make the navigation section explicitly separate." But doesn't this defeat part of the the purpose of having semantic elements?

Assuming I have only one navigation list of bullets and I am making them horizontal, adding background, etc., is it still ok to select the nav element over the class?

    <nav class="navigation">
        <ul class="links">
            <li><a href="">Shop</a></li>
            <li><a href="">Discounts</a></li>
            <li><a href="">Profile</a></li>
            <li><a href="">Blog</a></li>
        </ul>
    </nav>

And, if you're going to down vote me, please provide an explanation instead of just assuming I can intuit why you did it.

like image 569
Padawan Avatar asked Nov 29 '14 19:11

Padawan


1 Answers

Adding a class makes it easier to extend the page later. The class should carry semantic meaning in itself.

If you only select elements and then add more elements of the same type later, you'll have to add classes anyway.

like image 79
Jakub Arnold Avatar answered Nov 08 '22 22:11

Jakub Arnold