Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make up the css style

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how the css style is composed". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to form the css style".

The css style consists of a selector and a declaration block. The selector points to the HTML element that needs to be styled, while the declaration block contains one or more declarations separated by semicolons. Declaration blocks are enclosed in curly braces, and each declaration contains a CSS attribute name and a value; for example, "p {color:red;}".

The operating environment of this tutorial: windows7 system, CSS3&&HTML5 version, Dell G3 computer.

The css style (rule set) consists of selectors and declaration blocks:

The selector points to the HTML element that you want to style.

The declaration block contains one or more declarations separated by semicolons.

Each declaration contains a CSS attribute name and a value, separated by colons. Property is the property you want to change, and each property has a value.

Multiple CSS declarations are separated by semicolons, and declaration blocks are enclosed in curly braces.

Example:

Body {color: blue}

The purpose of the above line of code is to define the text color within the body element as blue. In the above example, the body is the selector, and the part enclosed in the curly braces is the declaration. The declaration consists of two parts: the attribute and the value, with color as the attribute and blue as the value.

Remember to write quotation marks

Tip: if the value is several words, put the value in quotation marks:

P {font-family: "sans serif";}

Multiple statements:

Tip: if you want to define more than one declaration, you need to separate each declaration with a semicolon. The following example shows how to define a central paragraph of red text. The last rule does not require a semicolon, because a semicolon is a separator in English, not a closing symbol. However, most experienced designers put a semicolon at the end of each statement, so the advantage is that when you add or subtract statements from existing rules, you minimize the likelihood of errors. It's like this:

P {text-align:center; color:red;}

You should describe only one attribute per line to enhance the readability of the style definition, like this:

P {text-align: center;color: black;font-family: arial;}

Space and case sensitivity

Most stylesheets contain more than one rule, while most rules contain more than one declaration. The use of multiple declarations and spaces makes the stylesheet easier to edit:

Body {color: # 000 position background: # fff;margin: 0 position padding: 0 position Font family: Georgia, Palatino, serif;}

Whether or not to include spaces does not affect how CSS works in the browser, and again, unlike XHTML, CSS is not case-sensitive. There is one exception: class and id names are case-sensitive when it comes to working with HTML documents.

Thank you for your reading, the above is the content of "how to constitute css style", after the study of this article, I believe you have a deeper understanding of how css style constitutes this problem, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report