2
I have a menu listing and would like to know the correct way to declare in HTML+CSS.
The HTML is like this:
<ul class="menu">
<li>Home</li>
<li>Empresa</li>
<li>Produtos</li>
<li>Blog</li>
<li class="logo"></li>
<li>Onde Comprar</li>
<li>Assistência</li>
<li>Contato</li>
</ul>
As for the CSS, I would like some hint.
Sure, I could put a class in each li and leave it the way I want, but I don’t know if it would be ideal, I would like to save code.
The CSS is like this:
ul.menu li{
font-family: "nexa_boldregular";
font-size: 12pt;
text-transform: uppercase;
color: #1d1d1b;
display: inline;
margin-right: 35px;
}
For example, if I want to style some li in particular, I would have to assign a class to it, right? As I did in the logo. The ideal in CSS would be like?
.logo, li.logo, ul.menu>li.logo?
There is no right or wrong, it will depend on your style of working or whether you will have any more element with the class
.logohas to specify that refers to the element within the.menuand use something like:.menu .logo– Jader A. Wagner
But, there is a more structured way. To save labor.
– Felipe Viero Goulart
In this case I suggest removing the html tags from the selector, use only when necessary... see this jsfiddle
– Jader A. Wagner
I edited the jsfiddle and now shows how to select only the desired element, in situations using the same classes, see...
– Jader A. Wagner
Thanks @Jader, very helpful!
– Felipe Viero Goulart