Text-wrap-mode - Property CSS

text-wrap-mode

Summary of characteristics of the text-wrap-mode property

Quick description
Defines whether newlines are allowed in a container.
Status
Standard
Applies to
Elements containing text.
Usable for
HTML
Predefined values
wrap | nowrap
Percentages
Not applicable.
Initial value
wrap
Inherited by default
Yes.
Discrète: during an animation, the text-wrap-mode property passes from one value to another without transition.
W3C Module
CSS Text Module
Document status: WD (Working Draft)

Syntax diagram of text-wrap-mode.

text-wrap-mode - Syntax DiagramSyntax diagram of the text-wrap-mode CSS property. See stylescss.free.fr for details. wrap wrap nowrap nowraptext-wrap-mode:;text-wrap-mode:;
Syntax diagram of the text-wrap-mode property.
The links in the diagram provide more details about the values.

Description of the text-wrap-mode property.

text-wrap-mode defines whether line breaks are allowed or prohibited between boxes of type inline.... For example, when several inline-box follow one another.
This property does not concern line breaks in a flex-box, which are managed by the property flex-wrap .

The property text-wrap-mode is a detailed property of the two shorthand property white-space and text-wrap.

See also :

  • text-wrap : Defines the handling of text wraps.
  • text-wrap-style : Defines how line breaks will be made.
  • wrap-before : Autorise ou non les sauts de lignes avant la boite.
  • wrap-after : Allows or does not allow line breaks after the box.
  • wrap-inside : Allows or does not allow line breaks in the box.
  • white-space : Defines how multiple spaces and carriage returns are restored.

Values for text-wrap-mode.

  • text-wrap-mode: wrap;

    Line breaks are allowed.

    The container below contains five blocks of the type inline-block.

    1
    2
    3
    4
    5
  • text-wrap-mode: nowrap;

    Line breaks are not allowed. The content may overflow its container..

    1
    2
    3
    4
    5
  • text-wrap-mode: initial; (wrap) text-wrap-mode: inherit; text-wrap-mode: revert; text-wrap-mode: revertLayer; text-wrap-mode: unset;

    Common values ​​are presented on these pages: initial, inherit, revert, revert-layer, unset.

Animation of the text-wrap-mode property.

The property text-wrap-mode animates "in jerks", meaning it suddenly switches from its wrap value to its nowrap value.

1
2
3
4
5
6
7
8
9
10

Manipulating the text-wrap-mode property programmatically.

With Javascript, change the value of text-wrap-mode.

In Javascript, here is how to modify the value of text-wrap-mode. Two syntaxes are possible: with the typical CSS notation, in kebab-case, and with the notation in camel-case.

Javascript
let el = document.getElementById('id'); el.style['text-wrap-mode'] = 'wrap'; // or let el = document.getElementById('id'); el.style.textWrapMode = 'wrap';

With Javascript, read the value of text-wrap-mode.

The property must have been assigned directly to the element itself via its style attribute, and not through a CSS selector.

Javascript
let el = document.getElementById('id'); let value = el.style['text-wrap-mode']; // or let el = document.getElementById('id'); let value = el.style.textWrapMode;

With Javascript, read the computed value of text-wrap-mode.

The calculated value is the one resulting from the cascade of inheritances, or if not available, the calculated value is the initial value wrap for text-wrap-mode).

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('text-wrap-mode');

With JQuery, change the value of text-wrap-mode.

JQuery also allows you to do the job.

JQuery

$('#id').css('text-wrap-mode', 'wrap');
// or
$('#id').css('textWrapMode', 'wrap');

With Javascript, read the value of text-wrap-mode.

JQuery
let value = $('#id').css('text-wrap-mode');

Test it yourself.

By clicking on the buttons below, you set the value to an item, then you either read back the assigned value or the calculated value. In the case of text-wrap-mode, this will be the same since this property only accepts predefined values.

Simulator.

The container below contains one element of type inline-block, one of type inline-flex, one of type inline-table, and two elements of type inline-block.

text-wrap-mode :
1
a
b
c
a1a2
b1b2
4
5

Browsers compatibility with text-wrap-mode..

Column 1
Correct processing by browsers of the text-wrap-mode property which manages line breaks inside an inline box.
1
text-wrap-mode
property
Estimated overall support.
86%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Opéra

Chrome

Safari

Firefox

Safari sur IOS

Edge

Chrome pour Androïd

Samsung Internet

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini

Historic of the text-wrap-mode property.

  • CSS Text Module Level 4

    This level 4 of this specification module describes the properties that affect typographic rules: text alignment and justification, word or character spacing, hyphenation rules, etc.
    Compared to level 3, several new properties have been added, particularly concerning line breaks, hyphenation, spacing before and/or after the text, etc.

    Regarding text-wrap-mode. First introduction of the text-wrap-mode property.
    WD
    September 22, 2015
    Working Draft.
    CR
    PR
    REC

See also, regarding text manipulations.

The property text-wrap-mode is part of the module CSS Text Module.
The following definitions are also described in this same module.

Properties:

hanging-punctuation
Langue française
Sets suspended punctuation (characters allowed to overflow into the margin).
hyphenate-character
Langue française
Defines the character that will be used as a hyphenation mark.
hyphenate-limit-chars
Langue française
Sets the minimum number of characters to allow hyphenation of a word.
hyphenate-limit-last
Langue française
Defines whether hyphenation is allowed at the end of a column, page, and so on.
hyphenate-limit-lines
Langue française
Sets the maximum number of successive lines ending in a hyphenation
hyphenate-limit-zone
Langue française
Sets the maximum number of spaces to allow or disallow hyphenation.
hyphens
Defines whether words can be hyphenated at the end of a line. The hyphenation of the words gives a more pleasant layout but can be annoying in some cases.
letter-spacing
Sets the letter Spacing.
line-break
Langue française
Defines line breaks for the CJK languages (Chinese, Japanese, Korean).
line-padding
Langue française
Adds a space at the beginning and end of lines.
overflow-wrap
Langue française
Word breaking for CJK languages and a few others.
tab-size
Langue française
Définit la taille des caractères de tabulation.
text-align
Langue française
Specifies how the element's text should be aligned.
text-align-all
Langue française
Defines the alignment of the lines of a text (synonym for text-align).
text-align-last
Langue française
Sets the alignment of the last line of paragraphs.
text-autospace
Langue française
Defines the space between adjacent characters (usable for CJK languages).
text-indent
Defines the indentation of the first line of paragraphs.
text-justify
Select the method used to justify the text: spacing between words or between letters.
text-space-collapse
Langue française
Defines how to handle spaces and multiple spaces in text.
text-space-trim
Langue française
Defines whether spaces at the beginning and end of the element's text should be kept or removed.
text-spacing
Short hand property for text-spacing-trim and text-autospace. Groups character spacing information for CJK languages.
text-spacing-trim
Langue française
Sets the spacing around CJK punctuation characters.
text-transform
Sets the text case (lowercase, uppercase, small caps...).
text-wrap
Langue française
Defines the handling of text wraps.
Text-wrap-mode
Defines whether newlines are allowed in a container.
text-wrap-style
Langue française
Defines how line breaks will be made.
white-space
Defines how multiple spaces and carriage returns are restored.
white-space-collapse
Langue française
Defines how successive spaces and newlines should be treated.
white-space-trim
Langue française
word-boundary-detection
Langue française
word-boundary-expansion
Langue française
word-break
Langue française
word-space-transform
Langue française
Normalize the spacing characters (CJK writings).
word-spacing
Langue française
word-wrap
Langue française
Word breaking for CJK languages and a few others.
wrap-after
Langue française
Allows or does not allow line breaks after the box.
wrap-before
Langue française
Autorise ou non les sauts de lignes avant la boite.