Home  >  Article  >  Web Front-end  >  How to eliminate the style of tags occupying a line by themselves in css

How to eliminate the style of tags occupying a line by themselves in css

WBOY
WBOYOriginal
2021-11-24 17:35:544348browse

In CSS, you can use the display attribute to eliminate the style of the label occupying a separate line. When the value of this attribute is "inline", the label will be set to be displayed as an inline element. At this time, there will be no line breaks before and after the label, and It will not occupy a line; the specific syntax is "label element object {display:inline;}".

How to eliminate the style of tags occupying a line by themselves in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

How to eliminate the style of tags occupying a separate line in css

The reason why tags occupy a separate line is because some tags are block-level elements. A block-level element occupies the entire horizontal space of its parent element (container) and the vertical space equal to the height of its content, thus creating a "block". If you want to prevent the label from occupying its own line, you only need to set the label as an inline element and remove the line breaks before and after the element.

At this time, you need to use the display attribute. You only need to set the display attribute value of the label to inline, which means that this element will be displayed as an inline element, and there will be no line breaks before and after the element. This will eliminate the effect of the label occupying a single line.

The example is as follows:




    
    
    
    Document

测试标签

测试文字

Output result:

How to eliminate the style of tags occupying a line by themselves in css

After adding styles to the tag:




    
    
    
    Document

测试标签

测试文字

Output result:

How to eliminate the style of tags occupying a line by themselves in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to eliminate the style of tags occupying a line by themselves in css. 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