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 Introduction to HTML and CSS (2016) Adding a New Web Page Write the HTML

I don't understand why <ul> isn't nested inside of <h2>?

as above :)

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

HI Ryan Straker

The best way to think of this formatting is to visualize it as it would be written on a piece of paper.

The <h2> tag should not be thought of as a container, but rather a formatter. This tag will make the font larger and bolder.
Imagine a menu at a restaurant:
The name of the restaurant will probably be in large print at the top of the menu. This would be like the <h1> tag. Now, lets say you wanted a burger. You would skim the menu looking for the section called "Burgers." The section title would be smaller than the name of the restaurant, but larger then then menu items, so this would be like an <h2>.
If it was all formatted as an <h2> element, than it would all look the same and the point of using an <h2> would become moot.

In short, it's a formatting thing, really. You could use heading tags inside a list to format the <li> tags, but this not in the way you are thinking, and is outside the scope of this post.

Overall, just remember that any heading tag should only contain one line of text and is almost always a title for the section following it.

I hope that this helps make more sense of the purpose and use of headings. If you would like to read up some more to further clarify, the MDN section for heading tags has some nice examples.

Keep Coding! :) :dizzy:

Hi, <ul> should only contain list items <li> like this:

<ul>

<li>1</li>

<li>2</li>

<li>3</li>

</ul>

If you head to: https://validator.w3.org/#validate_by_input and paste in:

<ul>

<h2>1</h2>

<h2>2</h2>

<h2>3</h2>

</ul>

You will get this error: Error: Element h2 not allowed as child of element ul in this context. (Suppressing further errors from this subtree.)

And vice versa :)

I would say that it is a matter of importance as h2 has greater importance in the overall markup than <ul> elements do , so, they cannot be contained by it,