search
HomeWeb Front-endHTML TutorialWeb front-end design: Html forces no line breaks tag usage code example_html/css_WEB-ITnose

In web page layout, such as article list title layout, no matter how many words there are, you do not want them to be displayed in new lines. You need to force the content to be displayed on one line. This can be achieved with the nobr tag. It plays the same role as word-break:keep-all. nobr is the abbreviation of No Break, which means line breaks are prohibited. Normally documents displayed in a browser will automatically wrap when reaching the bottom of the browser's banner, but if the text is contained in ~ tags, it will not wrap. Collected and organized by www.169it.com

1. nobr syntax

1

内容 nobr >

1

Content nobr >

The content without line breaks is placed between and That’s it, this tag has the same function as css white-space.

2. Features of the nobr tag:

1

2

3

即使浏览器的横幅不够,这里也不会换行。

div >

If the br line break tag is not encountered, the content will be displayed on one line. If the br line break tag is encountered, the content will automatically wrap after the br line break tag is encountered.

As a tag that defines appearance, it is not adopted in the W3C. If you want to use a style sheet to prevent line breaks, please specify nowrap in white-space. Examples of nowrap usage are as follows:

1

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

nobr标签实例 www.169it.com title >

ul{ border:1px solid #000; width:200px;}

li{ width:200px; line-height:22px}

style >

head >

第一排内容文字多加nobr标签测试内容 nobr > li >

第二排内容文字多加nobr标签不能排下 nobr > li >

第三排内容文字多没有加nobr标签 li >

第四排 文字少能排下 li >

ul >

body >

html >

2 3
Even if the browser banner is not enough, there will be no line wrapping here. div >
3. Code example of html nobr prohibiting content wrapping If here There are 4 lines of article title lists, set the width to 200px; the css line height is 22px; we use the ul li list layout for the content of the 4 columns, 2 of which add the tag to the content, one does not add the li content, and the other The content of li is small and the width can be displayed completely. 1. Complete html source code: table>

示例代码2:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 nobr tag example www.169it.com title > ul{ border:1px solid #000; width:200px;} li{ width:200px; line-height:22px} style > head > ; li > The second row of content text cannot be placed if the nobr tag is added nobr > li > There is too much text in the third row and no nobr tag is added li > There is too little text in the fourth row to be placed li > ul > body > html >

1

2

3

4

5

6

7

8

9

10

11

12

13

14

.AutoNewline

{

   width:300px;

   border:1px solid red;

}

style >

自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换

行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自

动换行自动换行自动换行 nobr > td >

tr >

table >

1
  • 2

    3

    4

    5

    6

    7

    8

    9

    10 11 12 13 14
    .AutoNewline {    width:300px;    border:1px solid red; } style > 自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换 行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自 动换行自动换行自动换行 nobr > td > tr > table >
    文章来源:Web前端设计:Html强制不换行
    标签用法代码示例
    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
    HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

    The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

    The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

    The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

    HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

    The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

    The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

    The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

    HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

    The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

    HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

    HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

    HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

    HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

    From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

    HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    DVWA

    DVWA

    Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

    VSCode Windows 64-bit Download

    VSCode Windows 64-bit Download

    A free and powerful IDE editor launched by Microsoft

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    SAP NetWeaver Server Adapter for Eclipse

    SAP NetWeaver Server Adapter for Eclipse

    Integrate Eclipse with SAP NetWeaver application server.

    Dreamweaver Mac version

    Dreamweaver Mac version

    Visual web development tools