/    Sign up×
Community /Pin to ProfileBookmark

I’ve been dying to know what a <section> of a document is…..except for the header, footer, and nav….it’s basically been a replacement for <div> for me.

What does everybody else use it for?

to post a comment
HTML

20 Comments(s)

Copy linkTweet thisAlerts:
@GomhonMay 11.2011 — From what I've read it's practically just a block as any other header, footer, or div tag. It also supports the Global HTML5 attributes.

Sources in links.

-Gomhon
Copy linkTweet thisAlerts:
@Big_O_1_May 11.2011 — I use sections as container elements to split up my page. For example my page will be structured like this:

[code=html]
<header></header>
<article>
<section id="article-info"></section>
<section id="article-main"></section>
<section id="sidebar"></section>
</article>
<footer></footer>
[/code]


I only use divs for wrapping elements that need something around it.
Copy linkTweet thisAlerts:
@LiveCityMay 12.2011 — One of the major improvements in HTML5 is the support for more semantic tags. Rather than wrapping everything in DIVs, you can now able to have more significant tag names.

The section tag is one of them, it's a simple block tag, that differs from the regular DIV in semantics.
Copy linkTweet thisAlerts:
@lizzycaplonMay 12.2011 — Yes nice sharing. such a i love know
Copy linkTweet thisAlerts:
@aj_nscauthorMay 12.2011 — Thanks to everyone.

LiveCity, I am aware that the tag was created for semantic purposes, I just don't understand the difference in semantics between a div and a section - they actually seem semantically equivalent to me - a div divides your page into [B]sections[/B].

But I started this thread to see what/if I was missing anything and see what everybody else uses section for, not really get a definition.
Copy linkTweet thisAlerts:
@LiveCityMay 12.2011 — Thanks to everyone.

LiveCity, I am aware that the tag was created for semantic purposes, I just don't understand the difference in semantics between a div and a section - they actually seem semantically equivalent to me - a div divides your page into [B]sections[/B].

But I started this thread to see what/if I was missing anything and see what everybody else uses section for, not really get a definition.[/QUOTE]


DIVs are used for just about everything these days. They are the containers, the content holders and the sections themselves. I think that the HTML5 work team is targeting this specific issue with such codes.

You don't have to wrap your header with another DIV, there's a HEADER tag for that. Same goes for FOOTER.

So, my assumption is that when you are dividing a website, use the tag that would be easier to maintain in the future - rather than guessing the role of every DIV in the overall layout. It's better than using ID, IMHO, because it's a whole different tag for a specific purpose.
Copy linkTweet thisAlerts:
@aj_nscauthorMay 12.2011 — 
....because it's a whole different tag for a specific purpose.
[/quote]


[B]But what is the specific purpose of a div vs the specific purpose of section?[/B] My point is, I don't see any difference whatsoever.

A div contains a section of your page.....so will a section tag....
Copy linkTweet thisAlerts:
@LiveCityMay 12.2011 — [B]But what is the specific purpose of a div vs the specific purpose of section?[/B] My point is, I don't see any difference whatsoever.

A div contains a section of your page.....so will a section tag....[/QUOTE]


Valid point. Allow me to clarify.

Let's say that you use only DIVs in your layout. The webpage itself is wrapped with a wrapper, within which there's a DIV for the header (which may contain additional DIVs for content), another DIV for the body of the website, which in turn contains a DIV for the side menu and the content itself (don't forget that every menu item is a DIV, and the content itself is filled with them also).

Too many DIVs, don't you think? They may be used properly, but the code is difficult to understand.

When using designated tags, you have a specific container for every type of content - wrap your header with a HEADER tag, same for the FOOTER, use SECTIONS whenever needed, and so on. The code produced that way is much more readable.

Also, consider screen readers for the visually-impaired. It would be much easier for them to know that the element they're rendering is a HEADER, rather than a DIV that was designated to serve such a purpose.
Copy linkTweet thisAlerts:
@aj_nscauthorMay 12.2011 — This thread was never about the header or footer tags....they have reasonably obvious semantic meaning.

It was about the section tag and if it's actually any more semantically valuable (which would be illustrated by the way people in this thread say how they use it).

After getting an series of extremely circular responses from you, it appears that your opinion on the subject is no, it holds no more semantic meaning than div. I think Gomhon, and myself included think this way as well.

I disagree with the fact that <section> makes code more readable than <div>.

I do like Big O's response of using it to split up an article into sections, rather than generically split (or [B]div[/B]ide) your page into sections).
Copy linkTweet thisAlerts:
@LiveCityMay 12.2011 — I presented my opinion, and some of the opinions offered by co-workers. The Header and Footer tags were an example, and a valid one IMHO, as they are offered within the same HTML5 schema.

I do believe that specific tags for specific purposes hold more semantic value. DIVs are rather general in today's web-design practice, although they seem to function the same way as the new codes.

Also, I do believe that wrapping blocks of code with a designated wrapper helps readability. For example - table header and table footer codes are no different in action from your usual rows, so why they were introduced in the first place? I think - for the same reason - allowing you to have more design elements to aid the overall scheme and readability.

The beauty of it is that you are free to choose whether you'd like to use it or not. The tag is available for you to use, so if you disagree with the points I've offered, you can choose to neglect them in your work. There are ARTICLE tags as well in HTML5, which are suggested for use when wrapping an article - same goes here: you may choose to use them to differentiate non-article content from article content, and you may stick to DIVs and IDs, just as with sections.

I think that the purpose of introducing them and suggesting them to replace DIVs is to differentiate different kinds of data with a specific tag. You are offered some flexibility, which depends on how will you use it creatively.
Copy linkTweet thisAlerts:
@svidgenMay 12.2011 — I just keep wondering whether there's really a point. I mean, most sites that require a team of folks to develop will likely be separated from the HTML anyway. They'll be tossing data structures at a header object, a footer object, a navigation object, etc. The tags that represent that data are probably somewhat irrelevant. And the class, structure, and variable names in the back-end code will hold much greater semantic value than a header tag will -- the backend objects will be things like RecipeName, Ingredient { Name, Amount, UoM }, Step { ActionDescription, IngredientList }, NutritionalInfo { VitaminList { .. } }, etc.

And honestly, if I were using the aforementioned list of objects, I might just use tag names that suit my application. Treat my document more like an XML document where I can give my tags true semantic value rather than the [I]lite[/I] semantic value offered by many of the new HTML5 tags.
Copy linkTweet thisAlerts:
@svidgenMay 12.2011 — On another note, here's an interesting analysis of the semantic tags: http://diveintohtml5.org/semantics.html#new-elements
Copy linkTweet thisAlerts:
@GomhonMay 12.2011 — I think Gomhon, and myself included think this way as well.[/QUOTE]

I agree. I think it's just adding to the thousands of ways you can say something within development.
Copy linkTweet thisAlerts:
@lvwdMay 12.2011 — Valid point. Allow me to clarify.

Let's say that you use only DIVs in your layout. The webpage itself is wrapped with a wrapper, within which there's a DIV for the header (which may contain additional DIVs for content), another DIV for the body of the website, which in turn contains a DIV for the side menu and the content itself (don't forget that every menu item is a DIV, and the content itself is filled with them also).

Too many DIVs, don't you think? They may be used properly, but the code is difficult to understand.

When using designated tags, you have a specific container for every type of content - wrap your header with a HEADER tag, same for the FOOTER, use SECTIONS whenever needed, and so on. The code produced that way is much more readable.

Also, consider screen readers for the visually-impaired. It would be much easier for them to know that the element they're rendering is a HEADER, rather than a DIV that was designated to serve such a purpose.[/QUOTE]


Thanks for clarifying. I have been using divs for everything so t his should help me organize it better as well
Copy linkTweet thisAlerts:
@aj_nscauthorMay 13.2011 — I just keep wondering whether there's really a point. I mean, most sites that require a team of folks to develop will likely be separated from the HTML anyway. They'll be tossing data structures at a header object, a footer object, a navigation object, etc. The tags that represent that data are probably somewhat irrelevant. And the class, structure, and variable names in the back-end code will hold much greater semantic value than a header tag will -- the backend objects will be things like RecipeName, Ingredient { Name, Amount, UoM }, Step { ActionDescription, IngredientList }, NutritionalInfo { VitaminList { .. } }, etc.

And honestly, if I were using the aforementioned list of objects, I might just use tag names that suit my application. Treat my document more like an XML document where I can give my tags true semantic value rather than the [I]lite[/I] semantic value offered by many of the new HTML5 tags.[/QUOTE]


This is a truly forward thinking method, I think. At the current time, I don't necessarily agree with what you're saying - I think search engines will, as HTML5 becomes more prevalent, take into account the semantic value behind the tags.

But, as a pro on your point, it's kind of like database normalization....why specify a limited number of tags (fields) when you can just let people define their own semantic tags, which is part of what XHTML was trying to do - harness the power of XML.

I guess despite the rise of the "semantic web" movement (that seemed to disappear within the past year or so after getting big a couple of years ago, briefly), HTML still hasn't really figured out a why to do it well.

I think a really good attempt was the "role" attribute, allowed you to use whatever tag(s) you wanted and apply semantic value separately using the attribute.

Interesting point of view.
Copy linkTweet thisAlerts:
@LiveCityMay 15.2011 — On another note, here's an interesting analysis of the semantic tags: http://diveintohtml5.org/semantics.html#new-elements[/QUOTE]

Thanks for sharing this, it was a good read!
Copy linkTweet thisAlerts:
@BluegillMediaMay 19.2011 — Perhaps I have this wrong, but I thought it was supposed to be articles within the sections. Like this for example:

[CODE]
<section id="a">
<article>Some content</article>
<article>Some content</article>
</section>
<section id="b">
<article>Some content</article>
<article>Some content</article>
</section>
[/CODE]


I use sections as container elements to split up my page. For example my page will be structured like this:

[code=html]
<header></header>
<article>
<section id="article-info"></section>
<section id="article-main"></section>
<section id="sidebar"></section>
</article>
<footer></footer>
[/code]


I only use divs for wrapping elements that need something around it.[/QUOTE]
Copy linkTweet thisAlerts:
@svidgenMay 19.2011 — See the W3C recommendation:

http://dev.w3.org/html5/spec/Overview.html#the-section-element

and one of their examples:

In the following example, we see an article (part of a larger Web page) about apples, containing two short sections.

<article>

<hgroup>

<h1>Apples</h1>

<h2>Tasty, delicious fruit!</h2>

</hgroup>

<p>The apple is the pomaceous fruit of the apple tree.</p>

<section>

<h1>Red Delicious</h1>

<p>These bright red apples are the most common found in many

supermarkets.</p>

</section>

<section>

<h1>Granny Smith</h1>

<p>These juicy, green apples make a great filling for

apple pies.</p>

</section>

</article>[/QUOTE]


This does not, however, mean that you cannot structure your document differnetly -- at least not as far as I can tell. Either element is valid inside the other. Correct me if I'm wrong, please.
Copy linkTweet thisAlerts:
@BluegillMediaMay 19.2011 — Yes it appears that you and Big O were correct. Poor naming in my opinion. I had though it was like a "section in a newspaper" that contained "multiple articles", but I guess that is a poor analogy since it goes the other way round.
Copy linkTweet thisAlerts:
@svidgenMay 19.2011 — Yes it appears that you and Big O were correct. Poor naming in my opinion. I had though it was like a "section in a newspaper" that contained "multiple articles", but I guess that is a poor analogy since it goes the other way round.[/QUOTE]

The W3C has it's opinion about what an "article" and a "section" are and how they "interact" with each other. Their intended use isn't necessarily the only [I]valid[/I] use.
×

Success!

Help @aj_nsc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...