HTML & CSS
Simple question. What's the difference between an <article> and a <section> semantic?
What's they're main purpose ? Is it worth my time to use? Are they important or can I continue using divs ?
Any info is well appreciated thanks
Simple? Don't be so sure. Plumbing the meaning of some of these new HTML elements seems to rival the big questions of Life sometimes. :rolleyes:
A <section> is for grouping related content, more commonly large sections of a page like a main content area. An <article> is more specialized, being for self-contained content—that is, content that could appear somewhere else and retain its meaning. A blog post, for example, could be posted elsewhere (in an RSS feed, for example) and still be meaningful without the original page context.
So should you use them? Don't feel obliged to. IMHO, they are silly elements, and I don't know if I'll ever use them. I don't believe there's any advantage to be had by using them at this point in time, at any rate ... except perhaps to make yourself feel all hip—which is, after all, the point of living ... isn't it?
Structure-wise, originally it was to mean an <article> would/could be like a mini-document or mini-page: a header, a footer, possibly asides and main content.
<section> was more broad, however due to sectionitis (a painful variant of divitis, and apologies to others medically educated for the horrid terminology) there's been some talk recently of stating something like, you shouldn't (or can't) make something a section unless the first bit of content in it is a header or heading (<h?> tag)... though someone brought up that ajax dynamically injecting content could make this a difficult hard rule.
But anyway that's something you could use as a rule of thumb... take what ralph said
An <article> is more specialized, being for self-contained content—that is, content that could appear somewhere else and retain its meaning.
and then use sparingly, and for sections ask yourself why it shouldn't be a div, and does it group a large chunk of content which starts with a <header> or heading <h?>? (even then, keep sections scarce and large, and use divs for all your little groupings you're doing for CSS, JS, etc).
Thank you both for the very well response, in my opinion I dislike the section and article semantics. I have a very found approach to the divs. i think I'll just stick with the divs until the day I really need section or article or until other day they become well developed and meaningful. Thank you for your responses.
You certainly aren't hurting yourself by sticking to divs. Currently the only semantics you actually get from those is, sections are "sectioning elements" of the HTML5 document outline, implemented badly by the JAWS screen reader and not much else (it'll announce each new section).
This topic is now closed. New replies are no longer allowed.