Two ways to use and reference CSS imports:
- External references
- External references, we can directly use the link tag to refer to a CSS file we have written;
- 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.
- It is now generally recommended to use CSS file references, which are the CSS style as a single. css file.
- Direct use
- Can be a style tag directly in the HTML file directly written, and then the page through the call;
- When writing a style sheet directly in an HTML file, you can import an external style from the @import file;
- 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