Css basics (3) and css Basics

Source: Internet
Author: User

Css basics (3) and css Basics
InheritanceInheritance is a rule that allows styles to be applied not only to a specific html Tag Element, but also to its descendants. For example, the following code: If a color is applied to a p tag, this color setting applies not only to the p tag, but also to all the child element text in the p tag. Here the child element is a span tag. CSS contains some styles that cannot be inherited, such:

border:1px solid red;
Special: Different css styles are set for the same tag. the browser determines which CSS style to use based on the tag weight. The label has a weight of 1, the class selector has a weight of 10, and the ID selector has a weight of up to 100. Inheritance also has the lowest value.
P {color: red;}/* weight: 1 */p span {color: green;}/* weight: 1 + 1 = 2 */. warning {color: white;}/* the weight is 10 */p span. warning {color: purple;}/* the weight is 1 + 1 + 10 = 12 */# footer. note p {color: yellow;}/* with a weight of 100 + 10 + 1 = 111 */
  CascadeMeaning: Multiple CSS styles can exist for the same element in an HTML file. If a style with the same weight exists, the final style is determined based on the order of these css styles and will be applied. Style priority: inline style sheet (inside the label)> embedded style sheet (in the current file)> external style sheet (in an external file ). In special cases of importance, you need to use the following code to raise some styles to the highest weight:
p{color:red!important;}
! Important must be written in front of the semicolon. Style priority: Default style of the browser <webpage maker style <style set by the user Text Layout-font, font size, and colorGeneral Font:
Body {font-family: "Microsoft Yahei";}/* better compatibility */body {font-family: "";}
Font size color:
body{font-size:12px;color:#666}

Text Layout-bold, italic, and underline
Bold: span {font-weight: bold;} italic: a {font-style: italic;} underline: span {text-decoration: underline;} text-decoration refers: text decoration. If the property value is none, no underline is displayed by default. none: Specify text without decoration underline: Specify text decoration with underline overline: Specify text decoration with line-through blink: the decoration of the specified text is flickering.

Text Layout-strikethrough, indent, line spacing (line height)
Strikethrough:. oldPrice {text-decoration: line-through;} adds strikethrough indentation to the text: p {text-indent: 2em;} 2em, which means twice the size of the text. Row Spacing: p {line-height: 1.5em;} sets the row spacing of a paragraph to 1.5 times.
  Section layout-text spacing, letter spacing, and alignmentSpacing of Chinese characters and letters:
P {letter-spacing: 50px;} (Chinese text and letter spacing) p {word-spacing: 50px;} (letter and letter spacing) Alignment: p {text-align: center;} center p {text-align: left;} center left p {text-align: right;} center right

 

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.