How to connect external css files in html?

您所在的位置:网站首页 html连接到css How to connect external css files in html?

How to connect external css files in html?

2024-07-14 21:11| 来源: 网络整理| 查看: 265

When learning the front-end, we should know that css adds various styles to html tags to tell the browser how to display the content in these tags. Since css is used to add various styles to html, how to introduce external css text into html? This article will introduce to you four methods for introducing CSS files into HTML. Let’s take a look at the specific content.

How to connect external css files in html?

How to connect external css files to html:

1. Use html to introduce css files directly in divs CSS style making div css webpage

html引入css文件Copy after login

Note: This method of introducing CSS files into HTML is not recommended because it will make the page have many tags, which looks cumbersome and does not reflect the advantages of CSS. Of course If you really want to use this method, you can use it in places that don't change often, but it's still not recommended.

2. Use the style built-in style in html that introduces css files.

Write css directly in the header

Copy after login

Instructions: This method of introducing CSS files into HTML is suitable for use when there are few pages. Advantages: speed Fast, all css controls are for this page tag, there are no redundant css commands; and there is no need to link css files externally. Read styles directly in the html document. Disadvantages: If there are many pages, it will be very troublesome to revise a single page. The page looks bloated, and CSS cannot be referenced by other HTML, resulting in a relatively large amount of code and troublesome maintenance. But most of the companies that use this method are rich. For them, the number of users is the key, and they have no shortage of people. Perform complex maintenance work.

3. Use @import to reference external CSS files when introducing css files into HTML

Introduce an independent .css file into HTML In the file, the import type uses css rules to introduce external css files. The

Copy after login

4. HTML introduces css files. Use link to reference external CSS files

Use the tag in the

tag pair of the web page to introduce external style sheet files, and use html rules to introduce them externalcss. Copy after login

Note: This method of introducing css files into HTML does not require the style tag, but directly refers to the external style by linking a style. It is recommended to use link to refer to the external css style. method.

The above are the four ways to introduce external css files to html. For more information about html and css, you can pay attention to the php Chinese website.

The above is the detailed content of How to connect external css files in html?. For more information, please follow other related articles on the PHP Chinese website!



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3