The second explanation doesn't overwrite the first; it simply targets specific elements that are children of the nav
element instead of the nav
element itself.
In this case, list items (li
) within unordered lists inside an element with the ID of nav
will be styled according to the second set of rules. The parent element with the ID of nav
will follow the initial styling directives. Elements under #nav
may also receive some properties through inheritance, like the font-family
, without direct specification. However, properties such as margin
require explicit declaration with margin: inherit;
.
If we had code like this:
#nav { margin: 13px 0 0 0; font-family: Helvetica, Arial, sans-serif;}
#nav ul li { margin: 0 20px 0 0; }
Then list items and other content within nav
lacking a defined font-family
would adopt a sans-serif font.
The text within curly brackets denotes properties and their respective values. For instance, margin
is a property, while the specified margins represent the values. Selectors preceding curly braces target specific elements.