Two CSS Basic syntax

Source: Internet
Author: User

CSS syntax rules consist of two main components: selectors, and one or more declarations.

The following shows you the CSS syntax structure:

For example:

h1{color:red;font-size:14px;}

Worth different writing and units

Many of these attribute values have different notation and units, such as:
1. Color: In addition to red English words, there are #ff0000 16 color values, and RGB (255,0,0)

or RGB (100%,0%,0%) these ways.

2. Font Size: units with Px,em and so on.

Here no longer one by one for example, I will fill in this part of the knowledge in the later finishing.

Remember to write quotes

Value is a number of words, you enclose the value in quotation marks. For example:

" Sans serif ";}

Multiple declarations
If more than one declaration is defined, separate each declaration with a semicolon. The last statement is also preferable to a semicolon, which avoids the error of adding or subtracting the declaration. In addition, only one attribute per line is written to enhance readability. For example:

p {  text-align:center;  Color:black;  Font-family:arial;}

Spaces and case
In general, whether the inclusion of spaces does not affect the effect of CSS in the browser, the same CSS is not sensitive to case.

However, please do not leave a space between the attribute value and the unit, if you use "margin-left:20 px" instead of "margin-left:20px", it is only valid in IE 6, but in Mozilla/firefox

or Netscape, but not working properly.

Similarly, class and ID names are case sensitive when it comes to working with HTML documents.

Therefore, for insurance purposes, strictly case-sensitive, and there can be no space between the attribute value and the unit.

Two CSS Basic syntax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.