CSS partial styling-Special font formatting, navigation bar pinning, block-level elements and inline elements, margin and padding default values for HTML elements, CSS style prioritization, and more

Source: Internet
Author: User

1. Some special font styles:

Indent 2 characters in first line: {text-indent:2em;}

Center horizontally: {text-align:center;}

Justify: {text-align:justify;}

Center vertically: {vertical-align:middle;}

Word spacing 2 characters: {letter-spacing:2em;}

Line spacing twice times: {line-height:2;}

2. The navigation bar is fixed somewhere on the page (relative to <body>):

{position:fixed;left:px;top:px;}

3. Block-level elements and inline elements:

Common block-level elements:<div>, <ul>, <ol>, <li>, <dl>, <dt>,

Common inline elements:, <input>, <select>, <strong>, <span>

Block-level elements cannot contain other block-level elements inside.

Block-level elements and inline elements can be passed {display:inline;} with {Dispay:block;} To convert.

4. The default value for margin and padding for a few HTML elements is not 0:

<body>, <p>, <ul>, <li>

5.CSS Style Precedence Summary:

(1) from high to Low: inline style (style directly written within HTML elements :style= ") >id selector >class selector > element;

(2) the introduced CSS style is higher than the style written within the HTML (<style type= "Text/css" >);

(3) with the same weight, the priority of important is high.

CSS partial styling-Special font formatting, navigation bar pinning, block-level elements and inline elements, margin and padding default values for HTML elements, CSS style prioritization, and more

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.