9 ms·
Semantic tags simply carry meaning in themselves whereas div-tags don't. There was a campaign to use standardized attributes to convey meaning (the campaigns na
by trb 15y ago
Semantic tags simply carry meaning in themselves whereas div-tags don't. There was a campaign to use standardized attributes to convey meaning (the campaigns name escapes me at the moment), but that's just a hack.
Just an example, if you want to scrape a website for the first 100 characters of its articles, you can just look for <article>-tags. If the website used <div>-tags you would have to figure out how to identify the articles (perhaps the author used the class .article or .main_article, etc.), and you'd have to do it for every website you want to scrape.
Screen readers would be another example of software that profits from semantic tags.
- joshuacc 15y agoAre you referring to microformats? http://microformats.org/ http://microformats.org/
- trb 15y agoAh yes, that's the one. Imho, it's an interesting concept and very useful for niche information, but can't replace the more semantic tags in html5.
- lukestevens 15y agoThese are the common arguments I also believed, but I dug into them for a book project and found they are pretty shallow. The HTML5 spec is such a mess when it comes to the new "semantic" elements that they are nigh on useless for anything. They're so broad (e.g. check out how broad the definition of "article" is) it's like calling a knife, a spoon, a plate, and table all a "fork" -- too broad to be useful. Div's are fine. They're all ignored equally by machines. Screen readers also pay zero to no attention to these tags -- heading tags are, however, very much used, but HTML5 intends to supersede that in a completely botched way too. It's not pretty. Also, you would imagine strong and em were useful as opposed to b and i. It turns out most screen readers ignore all of them entirely. Re the parent comment - as for the usefulness of true separation between presentation and content, I find it very promising for A/B testing layout, and therefore a worthy goal, but CSS really needs an actual layout system.
- rimantas 15y ago> These are the common arguments I also believed, but I dug > into them for a book project and found they are pretty > shallow. I am someone who does HTML/CSS for living, not just dog for one project, and these arguments are solid. Also CSS has a bunch of tool you can produce layouts with.