How to link the .css file in html code?


How the .css file is linked to html code?
<link href="main.css" rel="stylesheet">
what's the meaning of rel="stylesheet", i don't understand please help?
i'am a beginner.

and how it'll know, that where my main.css file is located?


from MDN:

This attribute names a relationship of the linked document to the current document. The attribute must be a space-separated list of the link types values. The most common use of this attribute is to specify a link to an external style sheet: the rel attribute is set to stylesheet, and the href attribute is set to the URL of an external style sheet to format the page. WebTV also supports the use of the value next for rel to preload the next page in a document series.

href tells <link> where the stylesheet is located (and the name), both are located in the same directory somewhere on the codecademy server