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

<link type="text/css">

When we link our style sheets to the html document we use the "link" tag. And we use "href" and "rel" attributes inside the link tag. But I have seen some people also use the "type" attribute and set it's value to "text/css". why they use it. what does that mean?

3 Answers

Tim Knight
Tim Knight
28,888 Points

To add on to Roy's point, both the link and the script tag now no longer require you to set the type. It's assumed that it's css or javascript respectively. Sometimes people who have been writing HTML for a long time still use them if they haven't kept up with the current standards. Also some tools like Dreamweaver and those similar applications that assist users in writing HTML will put them in—especially in older versions.

Thank you

Roy Penrod
Roy Penrod
19,810 Points

The "type" attribute tells the web browser the kind of information that is being returned from the location.

type="text/css" tells the web browser that it's a text document that should be treated as CSS.

type="text/javascript" tells the web browser that it's a text document that contains JavaScript.

type="image/png" tells the web browser that it's an image file in the Portable Network Graphics (PNG) format.

Here's a list of the most common media types you can take a look at.

THank u

Thanks you Tim and Roy