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

Do HTML5 tags get styled?

So, let’s say I have an article section on my blog and I want just that area to have a background color of purple.

Is it bad to give a section tag a class name (or ID) and change the color with it, or is it better to make a container div inside that section and use that instead?

1 Answer

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

The HTML5 tags add semantic meaning to your page. The division or div element is just a generic container that has no semantic meaning at all. It is not bad practice to give a section a class or an id attribute. You will find that this is a method to use. Think of using section over div as the same thing, except your adding semantic markup to your page. Therefore, they are both elements that can group content. Use div elements sparingly when there is no other appropriate tag to use.

You can add an id or class attribute to that specific article to give it the background color property you desire.