Original tutorial. For more information, see Webpage Tutorial.
We now need to use CSS for designing web pages. In this tutorial, we will teach you how to use CSS in the form of examples. We will use four examples to illustrate how to use CSS! The four examples in this tutorial help you understand when CSS works after adding CSS to HTML? And how to display it without adding CSS. Arouse your interest in CSS learning.
First, create a CSS file, open our notepad, and enter the following content:
P
{
Color: # ff0000;
Background: transparent;
}
Save it as style1.css (in this CSS file, we define the style of the p tag as red and the background is transparent)
Instance 1: save the following file as a. HTM file, and save it in the same directory as style1.css.
| The code is as follows: |
Copy code |
<Html> <Head> <Title> tutorial 1 on web tutorial network </title> <Link href = "style1.css" rel = "stylesheet" type = "text/css"/> <Style type = "text/css"> P { Color: #00ff00; Background: transparent; } </Style> </Head> <Body> <P style = "color: # 0000ff; background: transparent;"> blue text display </p> </Body> </Html>
|
Instance 2:
| The code is as follows: |
Copy code |
<Html> <Head> <Title> CSS instance 2 of Webpage Tutorial network </title> <Link href = "style1.css" rel = "stylesheet" type = "text/css"/> <Style type = "text/css"> P { Color: #00ff00; Background: transparent; } </Style> </Head> <Body> <P> Green text display </p> </Body> </Html>
|
Instance 3:
| The code is as follows: |
Copy code |
<Html> <Head> <Title> CSS instance 3 of Webpage Tutorial network </title> <Link href = "style1.css" rel = "stylesheet" type = "text/css"/> </Head> <Body> <P> red text display </p> </Body> </Html>
|
Instance 4:
| The code is as follows: |
Copy code |
<Html> <Head> <Title> CSS instance 4 of Webpage Tutorial network </title> </Head> <Body> <P> default browser text </p> </Body> </Html>
|
Through the above four examples, you can understand the definition of CSS and where it works.