Home  >  Article  >  Web Front-end  >  Which css style is not recommended?

Which css style is not recommended?

青灯夜游
青灯夜游Original
2021-04-06 18:35:182265browse

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.

Which css style is not recommended?

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.

Which css style is not recommended?

Run in the browser, the result is as shown below:

Which css style is not recommended?

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!

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