Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Jeremy Germenis
Jeremy Germenis
29,854 Points

Section or Not to Section?

That is my question!

In the How to Make a Website lessons I noticed that the main page content is placed in a section tag. When you run the page ( teamtreehousewebsite.com ) threw a html5 outliner, such as h5o, it returns back an "untitled section" from the use of the section tag without a proper headline. By using the section tag in this manner does it not cause a layer of disconnect between the content and the page?

Can someone at treehouse please explain the reasoning behind why you have chosen to use the section tag to contain the page content? Should I just ignore the "untitled section" labels in an outliner? or are these outliners unreliable?

2 Answers

I'm going to try to take a stab at this. For others that have the same question, this is the correct URL that was misspelled above. You can use this on a web based outliner to follow the conversation.

The reason why Nick Pettit's example is throwing back an 'Untitled Section" from the use of the section tag without a proper headline, is because the outliner is flagging this as a warning for you to correct it with a proper semantic structure. As Steve Faulkner, one of the lead authors of HTML5, has stated, "Remember, elements like <section> should not be used arbitrarily."

The spec for HTML5 says: "The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content. The theme of each section should be identified, typically by including a heading (h1-h6 element) as a child of the section element."

As Bruce Lawson points out in his excellent article on Sections, the basic guidance for using Sections is as follows:

  • Donโ€™t use it just as hook for styling or scripting; thatโ€™s a div
  • Donโ€™t use it if article, aside or nav is more appropriate
  • Donโ€™t use it unless there is naturally a heading at the start of the section

Therefore, in this regard Nick is coding the page incorrectly but it's (probably) not his fault. The specification for Sections has only recently changed.

This brings me to the next part

Can someone at treehouse please explain the reasoning behind why you have chosen to use the section tag to contain the page content?

Standardistas (A web developer who is actively involved in the creation, adoption, and/or promotion of web standards) recommend using semantically appropriate code in place of work-arounds or "hacks" to make things work correctly. By using current web specifications, this will help to ensure that code is future-proof. Using work-arounds to deliver the same results as specifications could cause potential hiccups as code becomes deprecated in the future.

By using HTML5 section elements, one has an ability to also code more efficiently for emerging trends, mobile technology, and also assistive technology (AT).

One of the major benefits of Outlining is that it provides a logical structure to individuals with disabilities (IWD). AT provides IWD a means to access the web as easily as everyone else. By designing to specification, we can ensure that we are providing the cleanest and most semantically appropriate content universally.

Should I just ignore the "untitled section" labels in an outliner?

No. The purpose of that is to show you the error, and what will happen should a user agent (such as Chrome or latest FF) attempt to provide an outline for the structure. I would recommend trying to fix it instead. By fixing it, this should be a <div> instead.

The specification for HTML5 is still being worked out and it is still roughly 13 years away from implementation. If you know your audience, you can use HTML5test to compare browser compatibility on Sections (and other tags).

Nick Pettit
Nick Pettit
Treehouse Teacher

Thanks for the detailed reply about this. In short, yes, the spec for sections was pretty volatile while I was writing and recording the course, and even now after release.

Jeremy Germenis
Jeremy Germenis
29,854 Points

Thank you for the clarification!