Style wordSpacing property
- Previous Page wordBreak
- Next Page wordWrap
- Go to the Previous Level HTML DOM Style Object
Definition and usage
wordSpacing
Property to set or return the word spacing in text.
Tip:To set or return the spacing between characters in text, use letterSpacing property.
See also:
CSS Tutorial:CSS Text
CSS Reference Manual:word-spacing property
Instance
Example 1
Sets the word spacing of the <p> element to 50 pixels:
document.getElementById("myP").style.wordSpacing = "50px";
Example 2
Using negative values:
document.getElementById("myP").style.wordSpacing = -3px";
Example 3
Returns the word spacing of the <p> element:
alert(document.getElementById("myP").style.wordSpacing);
Example 4
Difference between letterSpacing and wordSpacing properties:
function changeLetters() { document.getElementById("myP1").style.letterSpacing = "15px"; } function changeWords() { document.getElementById("myP2").style.wordSpacing = "15px"; }
Syntax
Return the wordSpacing property:
object.style.wordSpacing
Set the wordSpacing property:
object.style.wordSpacing = "normal|length|initial|inherit"
Property value
Value | Description |
---|---|
normal | Defines the normal spacing between words. Default. |
length | Specifies the space between words in length units. Negative values are allowed. |
initial | Sets this property to its default value. See also initial. |
inherit | Inherits this property from its parent element. See also inherit. |
Technical details
Default value: | normal |
---|---|
Return value: | A string representing the spaces between words in the text. |
CSS version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page wordBreak
- Next Page wordWrap
- Go to the Previous Level HTML DOM Style Object