The ways to connect CSS to html include: writing CSS styles directly in tags; writing CSS directly in the header through style; externally linking a CSS file through link; and using @import url when accessing multiple CSS files.
There are four ways to connect CSS to html, namely:
Method 1: Write the tag directly in the tag css control
<div style="width:100px;height:100px;border:1px solid #ccc"></div>
Method 2: Write the header directly to css
<head> <meta charset="UTF-8"> <title>Title</title> <style> p{font-size: 20px; color:red;} h1{color: blueviolet; font-family: "Arial Narrow"; } </style> </head>
Method 3: Externally link a css file
This is a commonly used method
<link href="css.css" rel="stylesheet" type="text/css">
Method 4: When accessing multiple css, when one css file refers to another css file
@import url(文件名.css)
Load after the page is loaded
The above is the detailed content of How to connect css to html. For more information, please follow other related articles on the PHP Chinese website!