Gap Between inline and inline-block

Source: Internet
Author: User

During front-end layout, we occasionally find that there is a small gap between elements with the inline/inline-block attribute. Some articles on the Internet say this gap is 6px, but I think it should be the width of a space.

Here we use inline-block as an example:

Below are some codes and their corresponding:

CSS:

span{        background:red;        display:inline-block;}

HTML:

<Span> Hello </span>

:

If you only change the HTML part

<Span> Hello </span>

Then:

We can see that there is a small gap in the middle, which is generated by the line feed.

If you change the CSS part at the same time, set font-size to a relatively large value.

*{    font-size:36px;}span{        background:red;        display:inline-block;}

 

We have

We can see that the gap has become larger.

If we replace the line feed of the HTML part with a space, we can achieve the same effect.

It can be seen that the gap between inline and inline-blocks is indeed generated by line breaks, and its size is a space width (here we will describe that the space width refers to the space width of the corresponding parent element ).

 

Gap Between inline and inline-block

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.