Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use anything but div? [closed]

Tags:

html

xhtml

web

In HTML/XHTML, why use anything other than div elements?

They are basic blocks that one can use to build entire pages. Sure, they don't add to the semantics of the page, but HTML isn't about semantics, it's about structure. And why should I be concerned about semantics?

Any thoughts?

Edit: So the statement "...HTML isn't about semantics, it's about structure." has caused some fuss; it is argued as being all about semantics, although div and span (perhaps the most common elements) break this rule. Perhaps then, a better question would be to ask: should HTML/XHTML be about semantics?

like image 435
TheBoss Avatar asked Aug 08 '12 19:08

TheBoss


3 Answers

Not all elements should be block level elements and the need to specify what kind of element a div is for every div on your page is ridiculous. It is also easier to read.

like image 196
edhedges Avatar answered Oct 27 '22 01:10

edhedges


Two important reasons:

  1. Search engines
  2. Screen readers

Search engines rank pages based on their content and also the semantics of that content. Adding the proper semantics to your content reinforces the intent of what the content is trying to communicate and that allows search engines to place higher value on that content.

Screen readers also rely on semantically-correct content. See this article for more information.

like image 42
John H Avatar answered Oct 27 '22 00:10

John H


Plus how your page is structured says a lot about what is on your page. Search engines will place higher importance on h1 than it will h6. It does more that display your data, it describes your data as well. HTML5 will have even more elements, so you better buckle up.

like image 25
D.A Avatar answered Oct 26 '22 23:10

D.A