Adding styles to our documents
So how do the CSS rules become part of our document? There are three ways:
- External style sheets
- Internal CSS
- Inline styles
External style sheets
This is the recommended way to add CSS to your site. It should be your goal for all style sheets of the production version of your site to be external. Simply add a line to the <head>
section of your site, which should look like the following:
<link rel="stylesheet" type="text/css" href="css/style.css">
<link>
is an HTML element we had not yet introduced. Its attributes are listed below:
rel
, to indicate the relationship between the HTML document and the linked file.type
specifies the MIME type of the document so the browser knows how to load it.href
is used to specify the location of the file. You may expect asrc
attribute here, like is used for<img>
tags, but the attribute to specify the file name in a<link>
element ishref
. For the file name, we recommend...