Home > Web Front-end > Front-end Q&A > The difference between css external linking and inline embedding

The difference between css external linking and inline embedding

藏色散人
Release: 2023-01-03 09:23:45
Original
3981 people have browsed it

The differences between css external linking and inline embedding are: 1. The writing methods of the three styles are different; 2. The three methods have different weight priorities in actual use. The order from high to low is "Embedding> ;Inline>Outline".

The difference between css external linking and inline embedding

#The operating environment of this tutorial: Windows 7 system, Dell G3 computer, CSS3 version.

What is the difference between external, inline and embedded css?

First of all, from a functional point of view, the functions of these three implementations are the same, and they can all achieve the typesetting and modification of content.

However, in terms of writing, they are different. Let’s distinguish them one by one:

1, inline style writing

<p style="color:red;"></p>
Copy after login

2, external style writing

Write a separate file with css extension, and then use the tag in to link the css style to html. For example:

<link href="你的css文件地址" rel="stylesheet" type="text/css"></link>
Copy after login

3, nested style writing

can be understood as nesting. Now write the required element tags in the text, such as span, and then write a separate css style in in . For example:

<head>
<style type="text/css">
span{color:re;}
</style>
</head>
Copy after login

Differences in priorities (Recommended: css video tutorial)

In actual use of the three methods, weight takes priority From high to low: embedded>inline>outline. More general styles are suitable to be isolated and used externally to improve reusability and reduce the coupling between styles and content; styles with few independent elements can be more convenient to use embedded.

The above is the detailed content of The difference between css external linking and inline embedding. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template