Home  >  Article  >  Web Front-end  >  How to connect css to html

How to connect css to html

清浅
清浅Original
2019-05-06 16:04:5414558browse

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>

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!

Statement:
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
Previous article:How to use iframeNext article:How to use iframe