How to handle horizontal gaps between inline elements in HTML

Source: Internet
Author: User

When you write HTML, write the inline elements that need to be next to each other, set their parent container's font-size to 0, and then set the font size of the inline elements, for example:

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title>    <styletype= "Text/css">        *{margin:0;padding:0;}Body{Color:#333}. Demo{Overflow:Hidden;font-size:0}span{Display:Inline-block;width:100px;Height:100px;Background-color:#ddd;Border:1px solid #000; }. Demo span{font-size:16px; }    </style></Head><Body>    <Divclass= "Demo">        <span>Set inline element to write on one line</span>        <span>Set inline element to write on one line</span>        <span>Set inline element to write on one line</span>        <span>Set inline element to write on one line</span>        <span>Set inline element to write on one line</span>        <span>Set inline element to write on one line</span>    </Div>    </Body></HTML>

Show:

How to handle horizontal gaps between inline elements in HTML

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.