Home  >  Article  >  Web Front-end  >  Why does the indentation of the first line of css have no effect?

Why does the indentation of the first line of css have no effect?

藏色散人
藏色散人Original
2020-12-22 11:06:413283browse

The reason why the indentation of the first line of css has no effect and the solution: 1. The element is not a block-level element. The solution is to use "display:inline-block;" to make the label have the attributes of some block-level elements; 2. The effect is overridden by a style with a higher priority. The solution is to modify the priority.

Why does the indentation of the first line of css have no effect?

The operating environment of this tutorial: Windows 7 system, css3 version. This method is suitable for all brands of computers.

Recommended: "css Video Tutorial"

In web page layout, the first line indentation is a very common effect. It makes your paragraphs look more standardized and tidy! Sometimes the first line indentation is set through CSS, but it has no effect. What is the reason?

The first line indentation in css uses the text-indent attribute, and its value allows the use of numbers, percentages, and inherit.

The reason why the indentation of the first line of css is invalid:

  • The element is not a block-level element

  • The effect has a higher priority The styles are covered.

Solution:

1. Determine whether the label is a block-level element. If not, you can use display:inline-block; to make it have the attributes of some block-level elements.

2. Check whether it is an invalid problem caused by !important priority!important > id > class > tag

Usage example:

p{
    text-indent: 2em;
}

Indent two The width of Chinese characters text-indent:2em;

(The unit em means the relative text size, 1em is the size of one text, and 2em is the size of two texts)

The above is the detailed content of Why does the indentation of the first line of css have no effect?. 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
Previous article:What does id mean in css?Next article:What does id mean in css?