HTML p Inline Distance <p> label up-down spacing CSS settings

Source: Internet
Author: User

In the HTML page, we see the article paragraph using the P tag between the upper and lower paragraphs there will be a line between the distance, here is the p and p paragraph distance between the adjustment of the setting?


HTML p line spacing p line spacing between upper and lower paragraphs

From the above HTML <p> Paragraph article demonstration effect, p and p up and down the paragraph line spacing is a certain distance. This paragraph p line spacing can be adjusted by the CSS adjustment. There are two common methods, one line-height adjustment and the other using margin to adjust line spacing.

I. Using CSS line-height to set P line spacing

Using the CSS row height style line-height can set the adjustment p line spacing, but also affects the upper and lower spacing between each line of text, so using line-height although can be used to set the HTML p line distance interval, but not very practical, General Line-height only sets the spacing between the upper and lower text.


One not set line-height and one set line spacing contrast effect

Obviously a CSS line-height is able to change the P-line and P-line spacing interval, but also let the text of each paragraph automatically line up and down the spacing also changed, so line-height is not practical.

Second, using margin to achieve p and p up and down line spacing change

1, the implementation of P and p up and down the line spacing and the same as the BR line 0 distance

1), key HTML p line spacing code:

    1. p{margin:0 Auto}

Explanation: Set the upper and lower spacing to p to 0, left and right auto spacing.

2), p line distance set to 0 complete code

  1. <! DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <Meta http-equiv= "content-type" content= "text/html; Charset=utf-8 " />
  5. <title>html p paragraph line spacing CSS settings thinkcss</title>
  6. <style>
  7. p{margin:0 Auto}
  8. /* Set P up/down distance is 0, left/right auto */
  9. </style>
  10. </head>
  11. <body>
  12. <p> First paragraph P test content <br /> First paragraph second row content </P>
  13. <P> second paragraph P test content <br /> Second paragraph second row content </P>
  14. <P> Third paragraph P test content <br /> Third paragraph second row content </P>
  15. </body>
  16. </html>

3), p line and line spacing setting effect


Margin setting p line spacing is zero

4), HTML P-line spacing is zero summary
This setting margin:0 auto (equivalent to maring:0 Auto 0 auto abbreviation, 0 on the left, self-adaptive at the bottom, 0 for the right, and adaptive for P), can achieve zero line distance.

2, HTML p line spacing adjustment major Small
Of course, this is also the use of CSS margin to achieve the p paragraph up and down paragraph line distance adjustment.

1), key HTML p line distance adjustment CSS Code
is still the space between the margin objects property.

    1. p{margin:10px Auto}

2), p line spacing becomes smaller and larger code description
Here respectively to not set margin, default original distance, set margin:10px auto, set line spacing up and down distance is 10px, set margin:30px auto, set line spacing up and down distance is 30px.

The three CSS codes are:
One: not set;
Two kinds: p{margin:10px auto}

Three kinds: p{margin:30px auto}

The three effects are as follows:


Change p paragraph up and down paragraph line spacing three kinds of distance change case

Three, HTML <p> paragraph line spacing summary

When setting the P line spacing distance, you need to consider whether it is necessary, in general, an article placed in HTML using the P tag to fragment the mark, it is not necessary to adjust the p paragraph distance. It's really necessary to adjust the line distance between articles in general by padding or margin.

HTML p Inline Distance <p> label up-down spacing CSS settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.