Css basics + css selector (element selector and link selector)

Source: Internet
Author: User

Css basics + css selector (element selector and link selector)

First, I will introduce how to import css styles in html webpages.

1. Intra-row style:

Use css for intra-row styles

 

2. In-page style: Set in the head label

  

Use css styles on the page

3. External link mode: First, you must prepare a css style sheet externally.
  

Set the style of the external link css style sheet. Note that heaf = "Here is the address of the css style sheet to be imported"

Next, I will introduce css cascade styles.

Element selector: class selector, id selector, class selector, and wildcard Selector

Type selector: select an element class label.

 

 

 

Id selector:

  

Class selector:

  

Wildcard character selection:

  

The type selected by the wildcard is abstract, so use it with caution!

Next, we will introduce the relationship selector, including the selector, subselector, adjacent selector, and sibling selector.

Contains the selector:

ul li{color:red;}
All the li labels below ul labels are set with styles

Sub-selector:

 Ol sublevel elements are selected 

Adjacent selector:

 Select the sibling level li element next to the li tag 

Sibling selector:

 Select All sibling elements behind the li tag 

 

The above is what I want to introduce.

In addition, I would like to add a few points:

First line indent: text-indent: 4em;

Center display: teext-align: center;

Priority:

In-row css> On-page css> external css

# Id>. class

If the style set later already exists, the style set later will be overwritten.

For example:

 

Specifically, it must overwrite the abstract

For example, if you use the set wildcard to select a matching element selector, the part that uses the element selector will not be overwritten by the wildcard selector.

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.