Word hyphenation in HTML. Wrapping Long Words Using CSS Which Attribute Defines Word Wrapping

💖 Do you like it? Share the link with your friends

The word-wrap property specifies whether or not to wrap long words that do not fit the width of the specified area.

brief information

Designations

DescriptionExample
<тип> Indicates the type of the value.<размер>
A && BThe values ​​must be output in the order specified.<размер> && <цвет>
A | BIndicates that you need to select only one value from the proposed ones (A or B).normal | small-caps
A || BEach value can be used independently or together with others in any order.width || count
Groups values.[ crop || cross ]
* Repeat zero or more times.[,<время>]*
+ Repeat one or more times.<число>+
? The specified type, word, or group is optional.inset?
(A, B)Repeat at least A, but no more than B times.<радиус>{1,4}
# Repeat one or more times separated by commas.<время>#
×

Values

normal Lines are not wrapped or are wrapped in places where wrapping is explicitly specified (for example, using
). break-word Line breaks are added automatically to ensure the word fits within the specified block width.

Example

word-wrap

Noun

Excellency

Animate noun

eleventh grader

Chemical substance

methoxychlorodiethylaminomethylbutylaminoacridine



The result of this example is shown in Fig. 1.

Rice. 1. Wrapping long words

Object Model

An object.style.wordWrap

Specification

Each specification goes through several stages of approval.

  • Recommendation - The specification has been approved by the W3C and is recommended as a standard.
  • Candidate Recommendation ( Possible recommendation) - the group responsible for the standard is satisfied that it meets its goals, but requires help from the development community to implement the standard.
  • Proposed Recommendation Suggested Recommendation) - at this stage the document is submitted to the W3C Advisory Council for final approval.
  • Working Draft - A more mature version of a draft that has been discussed and amended for community review.
  • Editor's draft ( Editorial draft) - a draft version of the standard after changes were made by the project editors.
  • Draft ( Draft specification) - the first draft version of the standard.
×

brief information

CSS versions

CSS 1 CSS 2 CSS 2.1 CSS 3

Description

The white-space property specifies how to display spaces between words. IN normal conditions Any number of spaces in HTML code appear as one on a web page. The exception is the tag

Text placed in this container is output with all spaces as it was formatted by the user.  So white-space imitates the way the tag works 
But unlike it, it does not change the font to monospace.

Syntax

white-space: normal | nowrap | pre | pre-line | pre-wrap | inherit

Values

normal The text in the browser window is displayed as usual, line breaks are set automatically. nowrap Spaces are not taken into account, line breaks in HTML code are ignored, all text is displayed on one line; at the same time, adding a tag
wraps the text on a new line. pre The text is shown taking into account all spaces and hyphens as they were added by the developer in the HTML code. If the line is too long and does not fit in the browser window, a horizontal scroll bar will be added. pre-line Spaces are not taken into account in the text, the text is automatically transferred to next line, if it does not fit into the specified area. pre-wrap All spaces and breaks are preserved in the text, but if the width of the line does not fit into the specified area, the text will automatically be wrapped to the next line. inherit Inherits the value of the parent.

The effect of values ​​on text is presented in table. 1.

HTML5 CSS2.1 IE Cr Op Sa Fx

white-space

Example

Fermat's Last Theorem
X n+ Y n= Z n
where n is an integer > 2



The result of this example is shown in Fig. 1.

Rice. 1. Applying the white-space property

Object Model

document.getElementById("elementID ").style.whiteSpace

Browsers

Browser Internet Explorer up to version 7.0 inclusive does not support the values ​​pre-line , pre-wrap and inherit . For