The link-in style is to put all the styles in one or more external style sheet files. This file has the extension of css. Through the link tag, the external style sheet (external style file named css) is linked to the HTML document. In this way, the structure and style can be divided into two files, which makes it easier to edit the style or structure. The basic syntax is: <link rel="stylesheet" href="text.css" /> Tips: The shortcut key is link+tab Specific steps① Create HTML and CSS files separately, with the file names ending with .html and .css respectively. In HTML, only the structure and the content that needs to be changed in style are written; For example: HTML file write: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Document</title> </head> <body> <div class="demo">Learn external style sheets with Zhang Wangwang</div> <div>Learn external style sheets with Zhang Wangwang</div> <div>Learn external style sheets with Zhang Wangwang</div> <div>Learn external style sheets with Zhang Wangwang</div> </body> </html> css file write: .demo{ color: blue; } At this point, the browser displays: As can be seen from the above code, we have set the color of the first line "Learn external style sheets with Zhang Wangwang" to blue, but because there is no connection between the .html and .css files, the first line of text in the browser does not display the edited color. ②Insert into the <head> of HTML <link rel="stylesheet" href="css file path" /> After that, press Ctrl+S and refresh the browser to display the following: You can see that the first line of text has turned blue~ Notice When practicing, it is best to put the .css file and the .html file in the same directory folder, and remember to save it first by pressing Ctrl+S after writing the style or structure, so that the results can be displayed better and faster. This is the end of this article about how to introduce CSS styles into HTML external style sheets. For more relevant content about introducing CSS styles into HTML, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: HTML table cross-row and cross-column operations (rowspan, colspan)
>>: CSS3 achieves infinite scrolling/carousel effect of list
How to delete environment variables in Linux? Use...
1. Embed is illegal The <embed> tag is a pri...
This article example shares the specific code for...
CSS naming rules header: header Content: content/c...
Table of contents Passing parameters between pare...
Demand background: Insert GIF dynamic images into...
I haven't worked with servers for a while. No...
In Windows operating system, the program to query...
1.1 Building the Directory Structure This operati...
html Copy code The code is as follows: <SPAN cl...
Table of contents Basic Types any type Arrays Tup...
This article shares simple HTML and music player ...
At this time, you can use overflow:auto; (when the...
This article shares the specific code for React t...
The most common, most commonly used and most gener...