The different ways to use CSS
There are three ways to use CSS:
- Â Inside an HTML tag with a
style
attribute (this method is not recommended, but you can still use it a little bit):Â
<p style'"font-size:12px"></p>
- Inside our
<head>
section in an HTML document with the tag<style>
:
<style>
p {
font-size:12px;
}
</style>
- CSS code can also be put into an external file, linked to the HTML document with the tag
<link>
. The file extension will be saved as a.css
file:
<link rel="stylesheet" href="css/style.css">
For this example, we will use the second option, but we'll learn the third option when we start building our own website.
Let's start by adding the <style>
tag in our <head>
section:
<head> <!--This is our head tag where we put our title and script and all infos relative to our page.--> <title>My Page Title</title> <style> </style> </head>