Home > Article > Web Front-end > What is the tag that does not wrap in html?
HTML is a markup language used to create web pages. It supports various tags and attributes and can achieve the presentation of various styles and effects. In HTML, it is often necessary to use some special tags for operations such as text typesetting and layout. Among them, tags without line breaks are a very commonly used tag, and this article will introduce them in detail.
The tags that do not wrap in HTML mainly include the following: <br>
, <wbr>
and <nobr>
, which are respectively used to indicate forced line breaking, line wrapping but not forced line breaking, and automatic line wrapping prohibited. Below we will introduce the usage and precautions of these tags one by one.
<br>
Tag<br>
Tag allows the text to be displayed on a new line there , the tag does not need to be closed, just write <br>
. For example:
<p>这是第一行<br>这是第二行</p>
The above code will insert a newline character between "This is the first line" and "This is the second line".
<wbr>
Tags<wbr>
Tags can be used to indicate that lines can be wrapped within words point, that is, a certain position within the specified word can automatically wrap, but will not force a line break. The tag also does not need to be closed, just write <wbr>
. For example:
<p>这是一个非常长的单词:超级长单词<wbr>(这个位置可以自动折行)</p>
The above code will insert a breakable point somewhere in the "super long word".
It should be noted that the <wbr>
tag only takes effect when the text is too long and must be wrapped. If the text itself can be completely displayed on the current line, this tag won't work.
<nobr>
Tags <nobr>
Tags can be used to disable text wrapping even if the text If it is too long to be displayed completely on one line, the part specified by the tag will not be forced to wrap to the next line. The tag needs to be used inside an element containing text and needs to be closed. For example:
<p><nobr>这是一个非常非常长的文本,虽然超过了一行的宽度,但是却不会被自动强制折行。</nobr></p>
The above code sets the text "This is a very, very long text. Although it exceeds the width of one line, it will not be automatically forced to wrap." is set to non-automatic from beginning to end. Zip line.
It should be noted that the <nobr>
tag has been abandoned in HTML5 and is not recommended for use. You can use white-space: nowrap;
in the style sheet to achieve the effect of disabling automatic line wrapping.
In addition to the three tags introduced above, there are a series of other styles in the CSS style sheet that can be used to control the line breaking and line wrapping effects of text. For example:
word-break
: used to control the way word line breaks; line-break
: used to control inline elements Line wrapping method; white-space
: used to control the display and processing of whitespace characters. In short, in HTML, mastering the use of these non-breaking tags and style sheets can help us better control the typesetting and layout of web page text.
The above is the detailed content of What is the tag that does not wrap in html?. For more information, please follow other related articles on the PHP Chinese website!