You can use the letter-spacing attribute to set the text spacing in css. You only need to add the "letter-spacing:length value;" style to the text element. The letter-spacing property is used to increase or decrease the space between characters; negative values are allowed, but will cause letters to be squeezed closer together.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css sets text spacing
In CSS, the property for adjusting the spacing between words is letter-spacing. You change the letter-spacing property of the label. Value to set the spacing between words within the label.
The letter-spacing property increases or decreases the space between characters (character spacing).
This property defines how much space is inserted between text character boxes. Because character glyphs are typically narrower than their character boxes, specifying a length value adjusts the usual spacing between letters. Therefore, normal is equivalent to a value of 0. [Recommended tutorial: CSS video tutorial]
Note: Negative values are allowed, which will make the letters squeeze closer together.
Attribute value:
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> h1 { letter-spacing: 3px; } h2 { letter-spacing: -3px; } div{ letter-spacing: 3px; } p{ letter-spacing: -3px; } </style> </head> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> <div>这是一段测试文本!</div> <p>这是一段测试文本!</p> </body> </html>
Rendering:
For more programming-related knowledge, please visit: Programming Video! !
The above is the detailed content of How to set text spacing in css. For more information, please follow other related articles on the PHP Chinese website!