CSS Display Properties: Block, Inline, And Inline-block - Medium
Có thể bạn quan tâm
Sign up
Sign in
WriteSign up
Sign in
![](https://miro.medium.com/v2/resize:fill:64:64/1*dmbNkD5D-u45r44go_cf0g.png)
Member-only story
CSS display properties: block, inline, and inline-block — & how to tell the difference![Daphne Watson](https://miro.medium.com/v2/resize:fill:88:88/1*AGB8rr-2Vls8gupsuKw1MQ.png)
Daphne Watson
Follow
3 min readFeb 8, 2017--
14
Share
Web browsers treat every element as a kind of box. However, CSS has two different types of boxes — block and inline.
A block element always starts on a new line, and fills up the horizontal space left and right on the web page. You can add margins and padding on all four sides of any block element — top, right, left, and bottom.
Some examples of block elements are <div> and <p> tags. As shown below, I’ve also added green padding on all four sides of each block element.
Inline Elements
Inline elements don’t start on a new line, they appear on the same line as the content and tags beside them. Some examples of inline elements are <span> , <strong>, and <img> tags.
When it comes to margins and padding, browsers treat inline elements differently. You can add space to the left and right on an inline element, but you cannot add height to the top or bottom padding or margin of an inline element.
Inline elements can actually appear within block elements, as shown below. I’ve added white padding on the left and right side of each inline element.
![Daphne Watson](https://miro.medium.com/v2/resize:fill:144:144/1*AGB8rr-2Vls8gupsuKw1MQ.png)
Written by Daphne Watson
357 FollowersTechnical writer based in California
FollowHelp
Status
About
Careers
Press
Blog
Privacy
Terms
Text to speech
Teams
Từ khóa » Html Css Block Elements
-
HTML Block And Inline Elements - W3Schools
-
CSS Layout - Display: Inline-block - W3Schools
-
Block-level Elements - HTML: HyperText Markup Language | MDN
-
Inline Elements - HTML: HyperText Markup Language | MDN
-
Block And Inline Elements
-
HTML - Blocks - Tutorialspoint
-
CSS Inline Vs Inline-Block Vs Block
-
HTML Block And Inline - Free Tutorial To Learn HTML And CSS
-
Inline And Block Elements In HTML - Scaler Topics
-
Difference Between Block Elements And Inline Elements
-
HTML Block And Inline Elements - GeeksforGeeks
-
HTML Block Level, Inline Elements - HTML Tutorials - W3resource
-
Block And Inline - CS193X: Web Programming Fundamentals
-
Conquer CSS By Understanding Inline And Block Level Elements