CSS tutorial: familiar with css syntax

Source: Internet
Author: User

The previous section describes the functions of CSS for creating web pages.

The syntax for declaring CSS styles is as follows:

Selector {selector {
Adequacy: Set Value; property: set value;
...
}

In a Selector, there is no limit on the number of parameter values that can be set. In a Selector, there is no limit on the number of attributes that can be set.

There are three main types of selector: Type selector, Class selector, and ID selector. There are three main types of selectors: Type selector, Class selector, and ID selector.

Type selector is (X) HTML Tag, such as <body> and
The formula is formulated in the form of "adequacy: Setting Value. The style is determined by "attribute: Set Value. For example, if we want to set that the text in an element is dimmed, we should use the following "Attention: Set Value": for example, to set the text in an element to yellow, use the following "attribute: Set Value 』:

Color: yellow;

In the above declaration, color is attention, and yellow is the set value. In the preceding Declaration, color is an attribute, and yellow is a set value.

In some cases, a certain degree of attention may have a fixed value. In some cases, a property may have several set values. These are usually because the flexibility is a good choice. These are usually because attributes are a shortcut. For example, there may be four preset values for the margin adequacy, and each value represents the maximum length of each region. For example, the margin attribute may have four set values, and each value represents the boundary length of each side.

Grouping

If several selector has the same format, they can be declared at the same time. If several selectors share the same style, they can be declared at the same time. This is called "grouping ". This is called "grouping ". For example, if
H1 h2 h3 {h1 h2 h3 {
Adequacy: Set Value; property: set value;
...
}

Descendant Selectors)

We can set that element a will use a certain style only when element a is within Element B. It can be set that a style is used only when element a is within Element B. If Element A is not in element B, the element a can have other similar expressions. If Element A is not in element B, the element a can have other styles. To reach this goal, we need to use the post-election tool. To achieve this goal, we must use the descendant selector.

The future selector declares the following syntax:

[Parent selector] [Child selector] {[Parent selector] [Child selector ]{
Adequacy: Set Value; property: set value;
...
}

In the above declaration, the form will be used only when the sub-selector is within the parent selector. In the above declaration, the style is used only when the child selector is within the parent selector. Such an alternative method can include a good alternative, instead of only two. This type of syntax can include several generations of selectors, rather than just two generations.

For example, the following announcement,

Li B {
Color: yellow;
}

It indicates that the text in <li> <B> is dimmed. Indicates that the text in <li> <B> is yellow. Text that is not in <li> <B> will not apply the natural color style. Text in <B> not within <li> will not apply the yellow font.

  • 2 pages in total:
  • Previous Page
  • 1
  • 2
  • Next Page

Related Article

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.