I. In-line
In-row styles use the style attribute directly in HTML tags.
<P style = "color: Red"> text </P>
Set the paragraph text to red.
However, remember that the final HTML should be independent and use the presentation document, so the intra-row style should be avoided anywhere.
Ii. Internal internal
The embedded internal style used for the entire page is in the head label, and the style label is surrounded by the style.
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<HTML>
<Head>
<Title> CSS example </title>
<Style type = "text/CSS">
P {
Color: red;
}
A {
Color: blue;
}
</Style>
...
The text of all paragraphs is red and the link is blue.
Like in-row Styles, you should keep HTML and CSS separated, so we only have a savior.
Iii. External
External styles are used throughout a variety of web pages. It is an independent CSS file, as shown below:
P {
Color: red;
}
A {
Color: blue;
}
If the token is saved as web.css, the link in the HTML is as follows:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<HTML>
<Head>
<Title> CSS example </title>
<LINK rel = "stylesheet" type = "text/CSS" href = "web.css"/>
...
Other external style methods will be discussed later in the tutorial. It is enough now.
From this guide, we will follow the above method ExperimentCodeIt is a good idea to use a text editor to create a file and save it as "web.css" in the HTML directory.
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<HTML>
<Head>
<Title> my first web page </title>
<LINK rel = "stylesheet" type = "text/CSS" href = "web.css"/>
</Head>
...
Save the HTML file. Now CSS is linked, but CSS is empty and NO content will change the HTML. When you start to learn CSS, you can add code to the CSS file to view the HTML refresh results.