When linking a CSS stylesheet to the HTML page I see this code:
<link href='style.css' rel='stylesheet'>
I understand href='style.css'
is telling the code to link to my 'style.css' page.
But what is the reason for the second part? = rel='stylesheet'
. Will this ever change?
Thanks in advance.
CodePudding user response:
<link
tags are not inherently CSS style sheets. There are lots of link
types, for example <link rel="icon" href="favicon.ico">
.
If you didn't tell the browser what you were linking to via rel
, then the browser would have no idea what to do with the content you're linking to.
CodePudding user response:
It actually defines the relationship of the linked styles with the document—also the preferred styles for different devices.
Here is a nice reference of the linked stylesheets: https://www.ch.ic.ac.uk/local/it/css/style-html.html
CodePudding user response:
The rel='stylesheet'
attribute is used to define the relationship between the linked file and the current HTML document.
The rel
stands for "relationship", and is probably one of the key features of the <link>
element — the value denotes how the item being linked to is related to the containing current document.
The current HTML document needs to tell the browser what you were linking to using the rel
tag, otherwise the browser would have no idea what to do with the content you're linking to.
There are many different kinds of relationship. Like @cee
You will find the list of some of Link
types in the following links