Style wordSpacing attribute
- Föregående sida wordBreak
- Nästa sida wordWrap
- Gå tillbaka till föregående nivå HTML DOM Style-objekt
Definition and usage
wordSpacing
Attribute sets or returns the word spacing in the text.
Tip:To set or return the spacing between characters in the text, use letterSpacing property.
See also:
CSS Tutorial:CSS-text
CSS Reference Manual:word-spacing property
Instance
Example 1
Set the word spacing of the <p> element to 50 pixels:
document.getElementById("myP").style.wordSpacing = "50px";
Example 2
Use negative values:
document.getElementById("myP").style.wordSpacing = -3px";
Example 3
Return 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"
Attribute value
Value | Description |
---|---|
normal | Define the normal space between words. Default. |
length | Specify the space between words with length units. Negative values are allowed. |
initial | Set this property to its default value. See also initial. |
inherit | Inherit this property from its parent element. See also inherit. |
Technical details
Default value: | normal |
---|---|
Return value: | A string that represents the spaces between words in the text. |
CSS version: | CSS1 |
Webbläsarstöd
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida wordBreak
- Nästa sida wordWrap
- Gå tillbaka till föregående nivå HTML DOM Style-objekt