Text wrap: the nowrap code has been abandoned. Why do some browsers still work?

Li Yang's Blog 05-06 527 Reading 0 Comments

Alas, when it comes to text wrap: nowwrap, I remember the reason why it was abandoned. To tell the truth, this attribute is really a headache! Do you think that since you decide to abandon it, it should be invalid? No, this has led some netizens to copy articles with their own format, making the articles unable to automatically wrap. For example, Google Browser, which makes programmers proud, let's take a look at what text wrap: nowrap is. In short, this property is used to control whether the text breaks when it exceeds the container width. If it is set to no wrap, it means no line breaks; If it is not set or set to normal, it is word wrap. It sounds very useful, doesn't it?

However, problems also follow. Oh, if only everything were so smooth! Unfortunately, in reality, there is no place to put long words, which is always met. In particular, in responsive design, the page size is variable and the element width is changeable. At this time, nowrap appears to be powerless.

 Text wrap: the nowrap code has been abandoned. Why do some browsers still work? Page 1

Nowrap will cause text to overflow the container, which not only affects the aesthetics, but also may damage the layout. When users encounter horizontal scroll bars or text truncation, the experience is unbearable! Therefore, in order to better adapt to different equipment and sizes, The W3C decided to discard text wrap: nowwrap, telling us whether to wrap or not, let the browser decide!

Although ` text wrap: nowrap` It has been deprecated, but some browsers may still support it for backward compatibility: to ensure that old versions of Web pages can still be displayed in new versions of browsers, browsers usually retain support for old properties. This is why some browsers can still recognize and apply ` text wrap: nowrap` Reason for. In order to ensure that your web page displays normally in all browsers, it is recommended that you use the 'white space' attribute` The white space attribute provides more options, such as' nowrap ',' pre ',' pre wrap ', and' pre line ', to better control the line breaking behavior of text. To prevent text wrapping, you can use the following CSS code:

 Class class name{   white-space: nowrap; }

Just set the text wrap: nowrap; Replace with white space: nowrap; You can solve the problem of not wrapping text. This will ensure that text does not wrap in all browsers.

However, the official suggestion is to try to avoid using abandoned attributes and adopt new solutions to achieve the same effect. This can ensure the compatibility and future maintainability of the web page.

So, although some browsers still support text wrap: nowrap, we should try to keep pace with the times, learn and use the latest technologies and standards, and make our web pages more modern and stable!

Article copyright notice: unless otherwise noted Lao Li's Notes For original articles, reprints or copies, please use hyperlinks and indicate the source.

Comment

Quick reply: expression:
 Addoil Applause Badlaugh Bomb Coffee Fabulous Facepalm Feces Frown Heyha Insidious KeepFighting NoProb PigHead Shocked Sinistersmile Slap Social Sweat Tolaugh Watermelon Witty Wow Yeah Yellowdog
Comment List (No comment yet, five hundred and twenty-seven People around)

No comment yet, let me say something

 cancel
 WeChat QR code
 WeChat QR code
 Alipay QR code