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

CSS How to Make a Website Customizing Colors and Fonts Resize Text

Janos Antal
Janos Antal
1,451 Points

Why do we use h1 if we modify almost everything?

Hello!

Why do we use h1 style for our names if we modify almost everything size,font, color etc.? And why do we apply the changes for the whole pages with h1 {...}, why not use only header h1 {...} instead?

cheers,

Janos

3 Answers

rydavim
rydavim
18,813 Points

HTML tags are intended to be semantic. You're using h1 in this case because your name is the most important element on the page.

Browsers have default styles for these tags, but these styles will almost always be reset or modified during the design process.

In this case, you won't be using the h1 tag anywhere else on the page, so you don't need to be more specific when selecting it.

Hopefully that's helpful. This is a somewhat subjective question, and coding practices are never going to be universal.

EDIT - Changed and shortened wording for clarity.

Brian Hayes
Brian Hayes
20,986 Points

When styling a website, using global styles for headings is an easy way to keep things consistent throughout the site, but also making it easier to write the HTML. In some ways it's a lot like using title styles in a word processor. Once you assign the style to a title and use that for each title throughout the document, all you have to do is update the global style to update them all. Using heading elements in HTML and globally styling them in our CSS is very much in the same light, as oppose to using <p> or <span> tags over and over and then using classes. This not only makes for a tougher to read document, but also will upset many search engines as well.

In short global styling of major HTML elements allows for a consistent style throughout the website, as well as an easy way to edit those styles and effect changes throughout the site, keeping our look consistent with minimal effort.

Janos Antal
Janos Antal
1,451 Points

thank you guys for the answers