Home  >  Article  >  Web Front-end  >  Can css adjust the spacing between words and the left and right sides of the words?

Can css adjust the spacing between words and the left and right sides of the words?

青灯夜游
青灯夜游Original
2022-05-18 17:30:195704browse

css can adjust the spacing between words and words. In CSS, you can use the letter-spacing attribute to adjust the left and right spacing between words. The syntax is "letter-spacing: spacing value;"; this attribute allows the use of negative values, which can be increased or reduced by the positive or negative value of the attribute. Reduce the space between characters (character spacing).

Can css adjust the spacing between words and the left and right sides of the words?

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

css can adjust the spacing between words and the left and right sides of the words.

In CSS, you can use the letter-spacing attribute to adjust the left and right spacing between words.

The letter-spacing property can set the space between characters (character spacing).

Syntax format:

letter-spacing:间距值;
  • Spacing value: Defines the fixed space between characters.

Note:

  • The letter-spacing 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.

  • For this attribute: each Chinese character is regarded as a "character", and each English letter is also regarded as a "character"! So pay close attention.

The letter-spacing attribute allows the use of negative values, and the character spacing can be increased or decreased by the positive or negative value of the attribute.

Example:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<style type="text/css">
			h1 {
				letter-spacing: 10px;
			}
			
			p{
				letter-spacing: 2em;
			}
			div{
				letter-spacing: -3px;
			}
		</style>
	</head>

	<body>
		<h1>This is header 1</h1>
		<p>这是一段文本!</p>
		<div>这是一段div文本!</div>
	</body>

</html>

Can css adjust the spacing between words and the left and right sides of the words?

(Learning video sharing: css video tutorial, web front-end )

The above is the detailed content of Can css adjust the spacing between words and the left and right sides of the words?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn