CSS word-spacing property is used to set the space between words or between words. Negative values are allowed. When a negative value is set, the space between words is reduced, otherwise the space is increased.
CSS word-spacing property
Function: word The -spacing attribute increases or decreases the space between words. Allows specifying negative length values, which causes words to be squeezed closer together.
Description: The word-spacing attribute defines how many whitespace characters are inserted between words in the element. For this attribute, "word" is defined as a string surrounded by whitespace.
Syntax:
word-spacing:normal|length;
normal: Default value, defines the standard space between words, which is equivalent to setting it to 0.
length: Defines the fixed space between words, which will adjust the usual spacing between words.
Note: Negative values are allowed. Taking advantage of the word-spacing property, it is possible to create documents with too widely spaced words, so be careful when using word-spacing.
Example of using CSS word-spacing attribute
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style type="text/css"> p.spread {word-spacing: 20px;} p.tight {word-spacing: -0.5em;} </style> </head> <body> <p class="spread">This is some text. This is some text.</p> <p class="tight">This is some text. This is some text.</p> </body> </html>
Rendering:
Reference for this article: https://www.html.cn/book/css/properties/text/word-spacing.htm
The above is the detailed content of How to use css word-spacing attribute?. For more information, please follow other related articles on the PHP Chinese website!