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:
- Inline:can not add height and width. But can add margin and padding
- Inline-block:can add height, width, margin and padding. Not take the whole row.
- 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