Why use <div id="header"> instead of <header> Should we use HTML5?


#1

In "CSS An Overview" why are we still using div ids for things that we now have semantic elements for in html5? Is this just to insure comparability with old sites? Will we be learning the html5 elements later to replace the divs?

on stack overflow Adesh M says:

Semantic elements means Elements with meaning. These elements clearly describes its meaning to both browser as well as to the developer.

and are examples of non-semantic elements; they don't tell anything about their content, whereas elements like , , and clearly define their content and are therefore referred to as semantic elements. - header is a semantic element that specifies a header for a document or section. headers should be used as containers for introductory contents. You can have several header elements in one document. - section is a thematic grouping of content, typically with a heading. - article specifies independent, self-contained content.

and so on...

W3 schools also says:

HTML5 semantic elements are supported in all modern browsers.

In addition, you can "teach" older browsers how to handle "unknown elements".

So why is codecademy teaching old methods?


#2

Because in HTML we don't throw away the baby with the bath water. Old methods are just as valid now as they ever were. You're dragging a dead horse.

Likewise, there is nothing new about 'teaching' a browser new elements. We could always do this once JavaScript was born.

I am a big fan of document traversal, but it doesn't mean we should completely do away with ID and CLASS. A <div id="header"> is the exact same thing as <header id="header"> when we add the attribute. It tells the browser, 'this is the only 'header' fragment.'

Consider that HTML5 permits multiple articles which have their own header and h1. We need some way to tell a search engine that the page header is unique and separate from the other header elements found in the document.

Furthermore, this is a course on HTML and CSS. HTML5 does not preclude or exclude HTML, it merely adds more elements to the specification. Any document can be well-formed and not use any semantic elements. If it follows the document outline guideline, it will be semantic by its structure, at least, if not by the many other indicators, headings, blockquotes and paragraphs, lists, tables, etc.

Tables even have their own semantic elements, starting with the <caption>. HTML5 does not deprecate any of this, save some older attributes. It takes minutes to make an HTML page (or XHTML) validate as HTML5.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.