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

高洛峰
Release: 2017-03-07 11:18:25
Original
2849 people have browsed it

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 tag to achieve no line breaks

The code is as follows:

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

The code is as follows:

<p nowrap>Hello world! Hello world! Hello world! Hello world!</p>
Copy after login


3Force no line breaks

The code is as follows:

p{ 
white-space:nowrap; 
}
Copy after login


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;}
Copy after login


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;}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template