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 CSS: Cascading Style Sheets Use ID Selectors

What difference will the following lines of code make in a browser

  1. <head> <style type="text/css"> p{ color : blue; } </style> </head>

  2. <head> <style> p { color: blue; } </style> </head>

2 Answers

Grace Kelly
Grace Kelly
33,990 Points

Hi Maneesh,

The type attribute specifies the type of content that is going to be placed inbetween the style tags and the value "text/css" indicates that this content is CSS so that the browser knows to expect css code :)

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Modern browsers by default will assume CSS when there is a style tag.

There would be no difference in function or styling of the website, and I see adding the "text/css" as being redundant and just adding more unnecessary lines of code.

It's not needed and, in my opinion, should not be used. Just the plain style tag is fine.

Jason