Detailed explanation of the 4 ways to import CSS files: inline, inline, external, and imported

Detailed explanation of the 4 ways to import CSS files: inline, inline, external, and imported

CSS import method - inline

Through the style tag attribute, the CSS key-value pair is directly written into the tag

<p style="width: 100px;height: 100px;background: red;"></p>
 <!--Note: This code describes a container with a width and height of 100px and a red background-->

CSS import method - embedded (embedded)

Use the style tag to introduce CSS attribute names and attribute values ​​into the HTML page. Usually the style tag is placed in the head tag. Why should CSS styles be placed in the head tag? Because the code is executed from top to bottom. If the structure is loaded first, the user will see dry content without beautification. Loading the style first and then the structure is like a child being born wearing clothes!

 <head>
     <style type="text/css">
        p{
             width: 100px;height: 100px;background: red;
         }
     </style>
 </head>

The above code also describes a container with a width and height of 100px and a red background, but it is introduced in an embedded way!

CSS import method other than chain

Introduce independent css files into HTML pages through link tags

<link rel="stylesheet" type="text/css" href="./style.css">

rel="stylesheet" describes the relationship between the current page and the document specified by href, which means that the document linked by href is a new style table, and type="text/css" specifies the MINME type, which is a css document. href="./style.css" specifies the location of the linked document

CSS import method

<style type="text/css">
     @import url("style.css");
</style>

Introduce a separate CSS file through @import url, url("style.css") specifies the location of the linked document

This concludes this article about the four ways of importing CSS files: inline, inline, external, and imported. For more information about CSS import methods, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Docker starts MySQL configuration implementation process

>>:  Our thoughts on the UI engineer career

Recommend

Detailed explanation of the steps to create a web server with node.js

Preface It is very simple to create a server in n...

MySQL backup table operation based on Java

The core is mysqldump and Runtime The operation i...

Navicat multiple ways to modify MySQL database password

Method 1: Use the SET PASSWORD command First log ...

How to change the root password in MySQL 5.7

Starting from MySQL 5.7, many security updates ha...

How to install openjdk in docker and run the jar package

Download image docker pull openjdk Creating a Dat...

Detailed process of drawing three-dimensional arrow lines using three.js

Demand: This demand is an urgent need! In a subwa...

Vue implements dynamic circular percentage progress bar

Recently, when developing a small program, I enco...

Discussion on the way to open website hyperlinks

A new window opens. Advantages: When the user cli...

HTML table tag tutorial (11): horizontal alignment attribute ALIGN

In the horizontal direction, you can set the alig...

JS+AJAX realizes the linkage of province, city and district drop-down lists

This article shares the specific code of JS+AJAX ...

Detailed explanation of the text-fill-color property in CSS3

What does text-fill-color mean? Just from the lit...

A brief talk about Mysql index and redis jump table

summary During the interview, when discussing abo...

Steps to transplant the new kernel to the Linux system

1. Download the ubuntu16.04 image and the corresp...

Pitfalls and solutions for upgrading MySQL 5.7.23 in CentOS 7

Preface Recently, I found a pitfall in upgrading ...