What is line height in css

青灯夜游
Release: 2023-01-05 16:11:42
Original
4533 people have browsed it

The line height includes the content area and the blank area that is symmetrically expanded based on the content area; generally speaking, it can also be considered as the vertical distance between the baselines of adjacent text lines. In CSS, you can use the line-height attribute to set the line height; this attribute sets the distance (line height) between lines, and negative values ​​are not allowed.

What is line height in css

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

1. Baseline, bottom line, top line

What is line height in css

  • The line height includes the content area and is based on the content area A symmetrically expanded white space; generally, it can also be thought of as the vertical distance between the baselines of adjacent text lines.
  • The baseline is not the lower edge of Chinese characters, but the lower edge of the English letter "x"

2. Line spacing and line height

行距和What is line height in css

3. Content area

What is line height in css

  • The area wrapped by the bottom line and the top line may not necessarily be in practice You can see it, but it exists.

4. Inline box

What is line height in css

    ##Inline box is just a concept, it cannot be displayed, but it And it does exist
  • its height is the line height
  • When there are no other factors (padding) affecting it, the inline box is equal to the content area
##5 . Line box

What is line height in css

#line box. Similar to the inner box of the same row, the row box refers to a virtual rectangular box of the current row
  • The height of the row box is equal to the maximum value of the row height among all elements in the row
Element pair The impact of row height

For inline elements such as em, strong, span, etc., their padding, margin, border-top, and border-bottom will not increase the row height.
    padding will be covered; margin will be reset to 0; border-top and border-bottom will also be covered.
  • padding-left, padding-right, border-left and border-right are available.

    The img element will affect the row height
  • Setting the padding, border and margin of the inline element will not increase the height of the outer element, as shown below:
  • 行内元素与What is line height in css
6. Set line height

In CSS we can use the line-height attribute to set the line height. The line-height attribute can be used to set the distance between lines (line height). Negative values ​​are not allowed.

The line-height property affects the layout of the line box. When applied to a block-level element, it defines the minimum distance between baselines in that element rather than the maximum distance.

The calculated difference between line-height and font-size (known as "line spacing" in CSS) is divided into two halves and added to the top and bottom of a line of text content. The smallest box that can contain this content is a line box.

Example:

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<style type="text/css">
			p.small {
				line-height: 90%
			}
			
			p.big {
				line-height: 200%
			}
		</style>
	</head>

	<body>

		<p>
			这是拥有标准What is line height in css的段落。 在大多数浏览器中默认What is line height in css大约是 110% 到 120%。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。
		</p>

		<p class="small">
			这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。
		</p>

		<p class="big">
			这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。
		</p>

	</body>

</html>
Copy after login

Rendering:

What is line height in css(Learning video sharing:

css video tutorial

)

The above is the detailed content of What is line height in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template