FAQ: A Closer Look at CSS - Link to a Stylesheet

This community-built FAQ covers the “Link to a Stylesheet” exercise from the lesson “A Closer Look at CSS”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Make a Website

FAQs on the exercise Link to a Stylesheet

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I’ve read some CSS textbook that says, when using <link> to introduce the CSS file, it’s fine to omit the type attribute since browsers today automatically detect its type.

I’m wondering if that still holds true. If we omit the type attribute, anything undesirable might happen?

HTML5 simplified things a little by establishing de facto MIME types for style sheets and scripts, text/css and text/javascript, respectively. That means under that doctype, we no longer need to declare it in our markup.

As far as undesirable outcomes, they would be rare, and only possible in older, out of date user agents. The odds are very small.

Modern browsers are most likely capable of reading file headers which clearly state the MIME type, regardless of the extension deployed.

If a lesson still expects us to use the type attribute on these resources, then humor the author and use it, otherwise, don’t be afraid to leave it out.

1 Like