css does not recommend using inline styles, that is, writing style attributes directly in the style attribute of the HTML tag. Disadvantages of inline styles: 1. Structural styles are not separated, which is not conducive to later maintenance; 2. Styles cannot be reused.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css It is not recommended to use inline styles.
css Inline style
Inline style is to directly add CSS code to the style attribute of the HTML tag, that is, it exists as an attribute tag of the HTML tag. In this way, you can easily define styles for an element individually.
Example:
Create a new html file, enter the following code, create three paragraphs p, and define an attribute style, which is used to define the display style of the paragraph, such as font color and font size.
Run in the browser, the result is as shown below:
From the example, we can see that the inline style is passed Defined using the attribute style, it can be anywhere in a p tag. At the same time, it can be found that if all labels in a large application use inline styles, the later maintenance investment will be very large. In this regard, the use of inline styles should be avoided as much as possible.
Disadvantages of inline styles:
1. No separation of structural styles is not conducive to later maintenance
2. Styles cannot be reused (not recommended)
(Learning video sharing: css video tutorial)
The above is the detailed content of Which css style is not recommended?. For more information, please follow other related articles on the PHP Chinese website!