CSS base syntax and selector usage

Source: Internet
Author: User

CSS syntax

selector{

Property:value

}

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

property is greater than 1, the attributes are separated by a semicolon

If the value is greater than 1 words, you need to enclose a quotation mark

p{font-family: "Sans serif";}


Selector grouping:

h1,h2,h3,h4,h5,h6{color:red;}

Inherited:

body{

Color:green;

}


css-Derived selectors

Define a style by the context in which the element is located

Css-id Selector

The ID selector can specify a specific style for an HTML element labeled with an ID

The ID selector is defined as "#"

The ID selector is often used to create a derived selector

css-class Selector

Class selector displays at one point

Class can also be used as a derived selector


css-Property Selector

Styling an HTML element with a specified property

Properties and Value selectors

body{    color:red;} H1,h2,p{    color: bisque;} /* derivation selector */li strong{    color: black;} Strong{    color: blue;} /*id Selector */#divId {    color: brown;} The/*id selector and the derived selector work together */#pid  a{    color: crimson;} /* class selector */.pclass{    color: chartreuse;} /* Class selector derived selectors work together */.divclass a{    font-size: 100px;    color:  black;} /* Property selector */[title]{    color: chartreuse;    font-size: 50px;} /* Property and Value selector */[title=te]{    color: chocolate;    font-size:  10px;} 
<! Doctype html> 


CSS base syntax and selector usage

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.