CSS3 Wrapping
Wrapping is a vital property for proper display of contents in web pages for if wrapping is disabled then the user could not display and view long lines that goes outside the window boundary and thus becomes useless.
Thus in this context it becomes necessary to handle preformatted text on web pages which can be done in CSS3 in several ways like using text-wrap, by using Pre-tag to display preformatted text on web pages and also by using the concept of word wrap in CSS3.Let’s see about each of these in detail.
Text Wrapping:
The text wrapping in CSS3 is handled by ‘text-wrap’ and ‘word-wrap’ properties. Let us see about these properties in detail.
text-wrap:
The general format of text-wrap property of CSS3 is as follows:
text-wrap: normal | unrestricted | none | suppress
In the above the default initial value is normal and the above format is used for handling text wrapping mode of text in CSS3. In the above we could find that the text-wrap can take any one of the values normal, unrestricted, none or suppress. Let us see what each of this denotes in brief.
Values of text-wrap:
normal:
When this value is taken by text-wrap mode then it denotes that the breaking of lines is allowed at the allowed break points.
unrestricted:
When this value is taken by text-wrap mode then it denotes that the line breaking can take place only between any two grapheme clusters and the final effect of line breaking would be in such as way that the Character shaping would have the effect of no breaking at all.
suppress:
As the name implies when this value is taken by text-wrap mode then the line breaking is suppressed within the element.
none:
When this value is taken by text-wrap mode then lines do not break any text that does not fit within the boundary get overflowed.
Word Wrap:
Like text wrapping as seen above CSS3 also can handle word wrapping by using the property named as word-wrap by which users can define break within a word and thereby prevent the overflowing when a word defined as string becomes long enough to fit inside a line box. But the vital point to note here is the property of word-wrap in CSS3 takes its effect and presence only when the text-wrap property tales its value as ‘normal’ or ‘suppress’.
The general format of word-wrap property of CSS3 is as follows:
word-wrap: normal| break-word
In the above the default initial value is normal and the above format is sued for handling word wrapping mode of text in CSS3. In the above we could find that the word-wrap can take any one of the values normal, suppress. Let us see what each of this denotes in brief.
Values of text-wrap:
normal:
When this value is taken by word-wrap mode then the lines are allowed to break only at the defined and allowed break points.
break-word:
When this value is taken by word-wrap mode then causes an unbreakable word to break provided there are no acceptable break points in the line. Also the breaking of words is done in such a way that the final character shaping would give the effect of word not being broken.
For example:
word-wrap: break-word;
The above statement define in Internet Explorer browser would cause the word-wrapping mode to take the value and effect of value break-word.
In the context of text handling in CSS there is yet another property named as white-space property.This property is similar and in fact a short alternative property for white-space-collapse and text-wrap properties. Let us now see about the white-space property of CSS3 in detail.
white-space Property:
The white-space Property of CSS3 depicts the way of handling and treating the white spaces or line returns in a text. Earlier version of CSS which was CSS2 provided four values for the property white-space. They are:
• inherit
• normal
• pre
• nowrap
CSS3 can take five possible values for the property white-space which are
- normal
- pre
- nowrap
- pre-wrap
- pre-line
The general format of text-wrap property of CSS3 is as follows:
white-space: normal | pre | nowrap | pre-wrap | pre-line
In the above the white spaces denotes any of space, tab, and End-of-line characters.
Let us see about each in brief:
normal:
When this value is taken by white-space Property then it sets the value for white-space-collapse property as ‘collapse’ and sets the value for text-wrap property to ‘normal’. Denoting the value of white-space as normal would enable the browser to consolidate sequences of white spaces into a single one and also line wrapping takes place appropriately as needed.
pre:
When this value is taken by white-space Property then it sets the value for white-space-collapse property as ‘preserve’ and sets the value for text-wrap property to ‘none’. Denoting the value of white-space as pre would prevent the browser from consolidating sequence of white spaces into a single one and also the wrapping the lines is prevented.
nowrap:
When this value is taken by white-space Property then it sets the value for white-space-collapse property as ‘collapse’ and sets the value for text-wrap property to ‘none’. When the white-space property takes the value of nowrap then as the name implies no wrapping of lines takes place but white space gets consolidated as needed by the browser.
pre-wrap:
When this value is taken by white-space Property then it sets the value for white-space-collapse property as ‘preserve’ and sets the value for text-wrap property to ‘normal’
pre-line:
When this value is taken by white-space Property then it sets the value for white-space-collapse property as ”preserve-breaks’ and sets the value for text-wrap property to ‘normal’