[CSS3] CSS Display Property:block, Inline-block, and Inline

Source: Internet
Author: User

Understanding the most common CSS display types of block, Inline-block, and inline would allow you to get the most out of Y Our HTML and use CSS frameworks like Bootstrap to their fullest.

Takeway:

    1. Inline:can not add height and width. But can add margin and padding
    2. Inline-block:can add height, width, margin and padding. Not take the whole row.
    3. Block:can add height, width, margin and padding, take the whole row.
<!DOCTYPE HTML><HTML><Head>  <MetaCharSet= "Utf-8">  <Metaname= "Viewport"content= "Width=device-width">  <title>JS Bin</title></Head><Body>  <P>Here are some text in a paragraph tag, a paragraph tag have a Dispay property of the block by Defualt.<spanclass= "inline">A span is an inline by defualt</span>But with some styling we can make it<spanclass= "Inline-block">Inline-block</span>. The Inline block would respect top and bottom margins and padding. We can also make it<spanclass= "Block">Block</span>By adding classes and styling them.</P></Body></HTML>

. Box{Border:1px solid Black;margin:5px;Display:Block;}P{Border:1px solid Black;}. Inline{Border:1px solid Blue;Display:inline;Margin-left:10px;Margin-right:50px;Padding-left:10px;Padding-right:50px;Margin-top:50px;width:500px;//doesn ' t work height:200px;//doesn ' t work}. Inline-block{Border:1px solid Red;Display:Inline-block;Margin-right:20px;width:200px;Height:50px;}. Block{Display:Block;Border:1px solid Green;width:50px;Height:100px;}

[CSS3] CSS Display Property:block, Inline-block, and Inline

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.