How HTML introduces CSS, and CSS selectors

Source: Internet
Author: User

Four ways to introduce CSS in HTML

1. Inline type

Style= "XXX" is written in the label

<= "color: #000;" >

2. Embedded type

Write the style tag in the head tag

< style >     H1{color:  #000; }</style>

3. Import type

Use @import= "Css_file" in the Style tab

< style >     @import "style.css"</style>

4. LINK Type

Using the link tag and href= "Css_file"

<rel= "stylesheet"  href= "Style.css " type ="" Media ="" />

Basic selector for CSS

1. Tag Selector: tagname{}

2. Category selector:. classname{}

3. ID selector: #idName {}

4. Wildcard: *{} means the element within the page

CSS Composite selector (Permissions: direct > Space > Comma)

1, intersection selection: Middle no space (between the basic selector)

Indicates that multiple selectors are satisfied

2. Set selection: separated by commas (",") (between basic selectors)

Indicates that the front and back selectors satisfy one of the

3. Descendant selection: separated by a space ("") (between the basic selectors)

Represents the latter in the former

Precedence in CSS

Style inline > #id样式 >.class style >tag styles

How HTML introduces CSS, and CSS selectors

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.