Multiple ways to write CSS

Source: Internet
Author: User
This time to bring you a variety of CSS writing style, CSS writing methods of attention to what, the following is the actual case, together to see.

Priority: External style < internal style sheet < inline style sheet;

Priority, that is: the right side of the selector with the same name overrides the left

1. Internal style sheet

CSS Code Copy content to clipboard

    1. <style>

    2. /* Internal style sheet, commonly used to override common styles */

    3. #headtip {

    4. Color:0xff5;

    5. }

    6. </style>

2. Use the link tag to declare one of the most common ways to use external resources in a document.

The CSS external style sheet specifies the encoded @charset= "Utf-8"; Need to be placed on the first line.

xml/html Code Copy content to clipboard

    1. <link href= "./my-common.css" rel= "stylesheet" media= "screen" type= "Text/css"/>

3.@ the way, the introduction of CSS, note that this is asynchronous loading, after the entire HTML loaded before loading, will cause the page to blink. It is not recommended.

CSS Code Copy content to clipboard

    1. <style>

    2. @import ' My-common.css ';

    3. </style>

4. Inline style sheet, the highest priority is the most straightforward, but not reusable is not easy to maintain.

xml/html Code Copy content to clipboard

    1. <body>

    2. <input type= "text" style= "color:0x550;font-size:30px;" />

    3. </body>

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

The method of horizontal vertical centering of three absolutely positioned elements

Waterfall flow layout with unlimited load Picture album effect

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.