Learn Web development-css_01 from the beginning

Source: Internet
Author: User

Two ways to use and reference CSS imports:

  1. External references
    1. External references, we can directly use the link tag to refer to a CSS file we have written;
    2. In the Link tab, we tell the browser through the rel = "stylesheet", which is a style file, while the REL has another value alternative, so that the user can choose the style, of course, this premise is the current page introduced more than one CSS style sheet file.
    3. It is now generally recommended to use CSS file references, which are the CSS style as a single. css file.
  2. Direct use
    1. Can be a style tag directly in the HTML file directly written, and then the page through the call;
    2. When writing a style sheet directly in an HTML file, you can import an external style from the @import file;
  3. The following is an example of a style reference;

    ?

    cssuse.html File Code:

    ?

    <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

    ???? <meta http-equiv= "Content-type" content= "Text/html;charset=utf-8" >

    ???? <link rel= "stylesheet" type= "Text/css" href= "Direct.css" >

    ???? <title>css use</title>

    ???? <style type= "Text/css" >

    [email protected] URL ("Http://localhost/cssUse/waysToImportCss.css");

    ???????? h2 {Color:green;}

    ???? </style>

    <body>

    ????

    ???? <p> style via link connection </p>

    ????

    ???? <a href= "#" >import Imported Styles </a>

    </body>

DIRECT.CSS File Code:

???? h1 {Color:blue;}

p {color:yellow;}

WAYSTOIMPORTCSS.CSS File Code:

???? a {padding:0 5px;}

a:hover {color:lightblue;}

a:visited {color:yellow;}

Learn Web development-css_01 from the beginning

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.