Home >Web Front-end >HTML Tutorial >The specific implementation method of preventing automatic line wrapping and forced non-breaking of divs in HTML

The specific implementation method of preventing automatic line wrapping and forced non-breaking of divs in HTML

高洛峰
高洛峰Original
2017-03-07 11:18:252847browse

This article introduces you to various implementations of p in HTML without automatic line wrapping. For example, you can use the nobr tag to achieve non-line wrapping, use the nowrap element, etc. Interested friends can refer to the following 1. Use the f44a345470ed5309298c118c07c6efac tag to achieve no line breaks

The code is as follows:

<p>Hello world!<nobr> Hello world!<nobr></p> 
2.用<用nowrap元素>标签

The code is as follows:

<p nowrap>Hello world! Hello world! Hello world! Hello world!</p>


3Force no line breaks

The code is as follows:

p{ 
white-space:nowrap; 
}


4. If there are two p, you can use float to achieve no line breaks

The code is as follows:

<p class="class1">hello </p> 
<p class="class2">world! </p> 
.class1 {float:left;}


5. Display can also be used in p to achieve non-line wrapping.

The code is as follows:

<p class="class1">hello </p> 
<p class="class2">world! </p> 
.class1 {display:inline;} 
.class2{display:inline;}

More details on how divs in HTML do not automatically wrap and are forced not to wrap. For articles related to implementation methods, please pay attention to 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