Understanding CSS Styles
CSS is all called Cascading style sheets (cascading style Sheets), which is primarily used to define the display style of HTML content within the browser, such as text size, color, font bold, and so on.
such as the following code:
p{ font-size:12px; color:red; Font-weight:bold;}
One advantage of using CSS styles is that by defining a style, you can have a uniform font, font size, or color for text in different page locations.
Advantages of CSS Styles
Why use CSS styles to set the appearance style of a Web page? The editor on the right is a piece of text, we want to set the text color of the three phrases ",", "", "" "," "", "" "," "", and then set 超酷的互联网 服务及时贴心 有趣易学 the style, and only need to write a CSS style statement.
Step one: Surround these three phrases with <span></span>. (See right-hand Code Editor 13 line)
Step Two: Write the following code: (see right-hand Code Editor 7-8 line)
span{ color:red;}
CSS code syntax
CSS styles consist of selectors and declarations , and declarations are made up of attributes and values , as shown in:
selectors , also called selectors, indicate the elements in the Web page to which you want to apply a style rule, as in this case, the text in all segments (p) in the page will turn blue, while other elements, such as OL, will not be affected.
declaration: in English curly braces "{}" is the declaration, the attribute and the value are separated by the English colon ":". When there are more than one statement, the middle can be a semicolon ";" Delimited, as follows:
p{font-size:12px;color:red;}
Attention:
1, the last statement may not have a semicolon, but for later modification convenient, usually plus a semicolon.
2, in order to use the style easier to read, you can write each code in a new line, as follows:
p{ font-size:12px; color:red;}
CSS Comment Code
Just like in HTML annotations, there are comment statements in CSS: used /*注释语句*/ to mark (use in HTML <!--注释语句--> ). Just like the following code:
CSS, Web style