This article will share how to introduce CSS style sheets and the advantages and disadvantages between them. It has certain reference value and I hope it will be helpful to everyone.
Style sheets can be introduced into CSS through three methods:
(1) Inline style
(2) Embedded style
(3) External styles
Each of these CSS styles has their advantages and disadvantages. Next, we will introduce them to you in detail
Inline styles
Features: (1) Inline styles are placed in HTML elements in the code.
(2) When using inline styles, the style will only affect the elements you select.
(3) Inline style has no selector
Example:
<div style="width:100px;height:100px;border:1px solid #ccc"><div>
This CSS inline style can only be changed The width and height of this div, it will not change the style of any divs or attributes on the page. This is one of the limitations of inline styles. This is not a best practice since they only make changes to specific elements, inline styles are also very specific. This makes it difficult to override them with other non-inline styles, and in fact, we rarely use inline styles on web pages.
Embedded styles
Features: (1) Web pages written by placing style tags