Home > Web Front-end > HTML Tutorial > How to connect css to html

How to connect css to html

清浅
Release: 2019-05-06 16:04:54
Original
14714 people have browsed it

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.

How to connect css to html

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>
Copy after login

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>
Copy after login

Method 3: Externally link a css file

This is a commonly used method

<link href="css.css" rel="stylesheet" type="text/css">
Copy after login

Method 4: When accessing multiple css, when one css file refers to another css file

@import url(文件名.css)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template