Is type="text/css" Needed for Style and Link Tags?

Please note that this post is over a year old and may contain outdated information.
When used in either an inline stylesheet or an external stylesheet, the attribute type="text/css" is optional as of HTML5. In the HTML4 spec it was needed, though browsers were forgiving. If omitted, browsers will default to text/css.

You can safely do this:

<link rel="stylesheet" href="style.css">

Just make sure you're using the new HTML5 doctype at the top of your HTML document:

<!DOCTYPE html>
I tested this all the way back to Internet Explorer 6.
Share This Post

Comments (1)

vera   Apr 12, 2020
thank you for the info!
Share This Post
H3XED © Nick Vogt   RSS   Policies   Twitter