Network administrator.
External CSS (external CSS) defines styles for multiple HTML pages with an external file (stylesheet). This way, you can change the look of the whole website, just a single CSS file.
To use external CSS, just link a reference to the file in the section of the HTML page.
OCTYPE html>
Network administrator.
This stylesheet can be written on any text editor. The file must not contain any HTML code and must be saved with the .css extension. This is an example of a section in this CSS file.
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p {
color: red;
}
color
in CSS determines the text color.font-family
determines the font used.font-size
specifies the font-size
used.OCTYPE html>
Network administrator.
border
defines the border around the HTML element.
p{
border: 1px solid powderblue;
}
padding
defines the space between text and border.
p{
border: 1px solid powderblue;
padding: 30px;
}
margin
determines the margin, ie the space outside the border.
p {
border: 1px solid powderblue;
margin: 50px;
}
The id
attribute is used to specify a specific style for a particular element.
Network administration is a technology website
Then specify the style for this element with id
#p01 {
color: blue;
}
Note : The id
of an element must be unique within a page.
When you need to define a certain style for a particular type of element, use the class.
attribute class.
I differences.
then define the style for the element with its own class.
p.error {
color: red;
}
External stylesheet can be referenced by the HTML file by the URL or the path to the current web page. The following example uses the full path to a stylesheet.
href="https://www.quantrimang.com/html/styles.css">
The following example leads to a stylesheet located in an HTML folder on the current web page.
The following example leads to a stylesheet located in the same directory in the current page.
Last lesson: Colors in HTML
The following article: Links in HTML