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 CSS Basics (2014) Getting Started with CSS External Style Sheets

Nathan Brazil
PLUS
Nathan Brazil
Courses Plus Student 2,756 Points

Why do you leave type="text/css" out of your link. What is the purpose for adding this to my links?

Good semantics?

1 Answer

In HTML4/XHTML the attribute type="text/css" was require for all link elements which linked to CSS files.

In HTML5 it is assumed that the link element will only link to a CSS file (I don't even think they can link to another type of file) so they can be omitted.


Stackoverflow has a really good explanation:

The HTML5 spec says that the type attribute is purely advisory and explains in detail how browsers should act if it's omitted (too much to quote here). It doesn't explicitly say that an omitted type attribute is either valid or invalid, but you can safely omit it knowing that browsers will still react as you expect.


See also: http://stackoverflow.com/a/5409146/989920