Why does the CSS link change here-no explantion? <link type = "text/css> to <link type="text/css"rel="stylesheet" href="stylesheet.css"/>

In the previous lesson 6 we were told to link the HTML using:

link type = “text/css”

Magically in this lesson 7 the link becomes :

link type="text/css"rel=“stylesheet” href=“stylesheet.css”

Without using the above think, the page won’t link the the CSS. But are the additions to the link, rel and href, that are not explained? There are two extra pieces there than need explanation. Did I miss something?


the course html + css is written by multiply people, the person who wrote the <link> with the slash values xml, the slash is xml syntax.

I can understand this can be confusing, but not much i can do about that. Most of the time, without the slash the link is good

I don’t really understand your reply. Not sure what you’re talking about. Sorry.

My question was not about syntax but about the code. I left the tags off the ends since it would not print those in the comment for some reason.

I want to know how the rel and href tags are needed.
In lesson 5 it does introduce them, but not explain why they are needed.

What is the purpose of rel and href in the to the stylesheet?

rel = relationship
href = hypertext reference
type = what type of file it is

  • href links the the file(your CSS ) to the HTML
  • rel tells the browser what’s it’s relationship which is the stylesheet
  • type is self explanatory… What type of file it is… In this case it’s text and CSS

If you leave the tags put it won’t be linked thus CSS won’t be rendered… Yes they are needed without href the file out be linked

Hope this clears up :slight_smile:

I assume there are other ways to link that we’ll learn, but this particular link is not explained well in the lesson. It seems as if the code
link type= text/css
should be enough, but I guess I see why the others are needed now.

Okay. Thanks. Gives it a bit more context than the lesson.


No, it is not enough. The latest html5 standards allow you to leave out type, but you still need rel and href. Href is most certainly important, since it tells html where the css file is located.

Codecademy doesn’t have the most extensive background, MDN is already more, if you want to understand even better you should check out the document about link with the latest html5 standards on w3c, which you can find here

1 Like

Thanks for the link to the more indepth explanations on linking

I’m pretty knew to linking so even the basic stuff is mostly new to me.

Much obliged for the responses. I haven’t commented much here, but after the rapidity and the ethos (sorry for the 5 dollar words) I’ll use these forums more.

1 Like

2 posts were split to a new topic: Css a overview