Zero-based CSS Introductory Tutorial (2) - How to Apply CSS

1. Mission objectives

The previous article introduced the role of CSS, which is used to set the style of web pages. This article uses a basic introductory example to show how CSS applies styles to web pages

2. How styles are applied

Ok, now we want to apply the green style to the first label above, which is the following code.

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <p style="color: aquamarine;">无边落木萧萧下</p>
  <p>不尽长江滚滚来</p>

</html>

So how to apply it, in fact, can be realized through the style attribute of HTML. In other words, the value of the style attribute is the part of the CSS code we want to write.

Through the style attribute, we can apply the CSS style code to the specified label.

Look at the code below, we set the style for the p tag, the value of the style attribute is color:aquamarine; that is,
the effect of the CSS code is as follows
insert image description here

3. Summary

From the above example, it can be found that CSS applies styles to labels through the style attribute.

We only need to remember the names and values ​​of some CSS styles to master CSS.

You can try changing green to other colors, such as red and black, to see if it works.

Guess you like

Origin blog.csdn.net/weixin_61808806/article/details/128208343