Home  >  Article  >  Web Front-end  >  What is the difference between CSS external links and inline styles?

What is the difference between CSS external links and inline styles?

青灯夜游
青灯夜游Original
2021-01-19 16:20:593905browse

Difference: The CSS external link method is to write the css code separately in a file with the extension ".css", and then use the link tag to link to the html. Inline CSS is to directly use the style attribute to write the css code in the HTML tag. Inline types are given higher weight than inline types.

What is the difference between CSS external links and inline styles?

The operating environment of this tutorial: windows7 system, css3&&html5 version, Dell G3 computer.

(Learning video sharing: css video tutorial)

CSS external link style--external link style sheet

Outside A chain style sheet is to write a separate file with a css extension, and then use the 2cdf5bf648cf2f33323966d7f58a7f3f tag in 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1 to link the css style to html. For example:

<link href="css样式的名字(一般自己取).css" rel="stylesheet" type="text/css">

CSS inline--inline style sheet

Inline CSS can also be called inline CSS or row-level CSS, which is directly in the Introduced inside the tag.

For example:

<body>
<p>莱昂纳多演的<span style="color:red">了不起的盖茨比</span>非常好看。</p>
</body>

The obvious advantage is that it is very convenient and efficient; but it also has the disadvantage of not being able to reuse styles. If the number of lines of code reaches a certain length, it is not recommended. . Inline CSS is often used as a test to find bugs in the code.

The difference between CSS external link type and inline type

There is actually no essential difference between CSS external link type and inline type. Connections are easy to manage, and writing the same attributes together avoids code redundancy.

The weight priority is from high to low: inline > external.

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of What is the difference between CSS external links and inline styles?. 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