-2

If I have no:

nav {
    color: red;
}

and use it as <nav>, i.e.with no class= or style=, does it have any impact on layout and/or style?

Reading it, I assume there is no impact (same for the other Semantic Elements). And of course, marking parts with these then help for accessibility, etc.

David Thielen
  • 28,723
  • 34
  • 119
  • 193
  • 1
    What kinf of impact are you talking about? – j08691 Apr 21 '23 at 21:49
  • Layout, yes; they'll act as `
    `s.
    – ceejayoz Apr 21 '23 at 21:52
  • @j08691 any impact whatsoever. I've got them in there to provide the semantic markup. But I want the rendered page to be identical to their not being there. – David Thielen Apr 21 '23 at 21:54
  • @ceejayoz like a
    with no style/class is fine. All that means (I believe) is what it contains needs to be block of content. And what's in them is that.
    – David Thielen Apr 21 '23 at 21:56
  • 1
    As ceejayoz noted, alone all they are are block level elements. – j08691 Apr 21 '23 at 21:57
  • If either of you write that as an answer, happy to accept it. thanks – David Thielen Apr 21 '23 at 22:01
  • Here is a [list of all block level elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements). These all "act" the same if no styles are applied - in terms of the box model. – disinfor Apr 21 '23 at 22:19
  • Does this answer your question? [What is the difference between "block box" and "block-level element"?](https://stackoverflow.com/questions/75090912/what-is-the-difference-between-block-box-and-block-level-element) – disinfor Apr 21 '23 at 22:21

1 Answers1

0

These html elements that you are listing (header, nav, main) all have the same styling as a normal div when rendered.

The only purpose of their naming being different to a div is for semantic reason which is useful for screen readers or other developers reading your code.

It will not affect the styling at all.

Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143