CSS introduction (1)

Source: Internet
Author: User

This article is a summary of Chapter 10th of HTML & cssdesign and build websites.

A css rule consists of two parts:Selector {declaration}A declaration is a combination of property: value. Multiple selectors can have the same declaration, separated by commas.

H1, H2, H3 {font-family: Arial; color: yellow ;}

After CSS is written, how can we make it show results?

There are two types: external, internal, CSS, and link, the other is that CSS code is directly embedded in HTML,

External: It must be placed under the head node. This is understandable. After all, you must know these styles before introducing the body,

<link href="css/styles.css" type="text/css" rel="stylesheet" />

Internal:

    <style type="text/css">      body {          font-family: arial;          background-color: rgb(185,179,175);}      h1 {          color: rgb(255,255,255);}    </style>

Selector can have many types:

A) Global * {} indicates that all elements on the current page are effective.

B) element name, such as H1, H2, H3 {}

C) Class, the class of the element. There must be a number here ,. note {} or P. note {}, the difference between the two is that the previous one is useful for all the nodes where the class is the note, note is only useful for the class under the node whose name is P.

D) ID, the element ID. It starts with the # symbol. It is similar to jquery. # Introduction {}

E) There is also a location-related selector,

Child: LI> {}

Descendant:
P {}

Adjacent sibing:
H1 + P {}

General sibing:
H1 ~ P {}

If there are so many selector conflicts, it is generally more specific to replace more general global rules. Another way is! Important

p b {color: blue !important;} 

There are also many types of properties, which will be introduced in the next 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.