{"id":2278,"date":"2021-11-26T09:53:06","date_gmt":"2021-11-26T09:53:06","guid":{"rendered":"https:\/\/blog.embold.io\/?p=2278"},"modified":"2021-11-26T10:20:20","modified_gmt":"2021-11-26T10:20:20","slug":"difference-between-inline-inline-block-and-block-layout-elements","status":"publish","type":"post","link":"https:\/\/blog.embold.io\/es\/difference-between-inline-inline-block-and-block-layout-elements\/","title":{"rendered":"Difference between inline, inline-block, and block layout elements"},"content":{"rendered":"\n<p>The inline, inline-block, and block layout values are all possible values for the CSS display properties. Many newbie frontend developers usually struggle with understanding the difference between the three, and it\u2019s a common frontend developer interview question. <\/p>\n\n\n\n<h1>display:inline<\/h1>\n\n\n\n<p>When an element is styled with <code>display:inline<\/code>, it will not start on a new line, will only take up as much width as the content it contains, and will not cause a line break after it.&nbsp;<\/p>\n\n\n\n<p>For example, consider the code below: <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/rsB8Tfr_AooEK2S9VY2ttZLHaAxYxovOISppyjOPxVn-BlmTcVgSt5CkbPaGYO5jXSvHeY9_g-dYgJDlszg0Eq1k9WPPTG9gxpaUqIzQ0Zoa7lfzwb6v3pTd4rwyIiY3q1V-7n3s\" alt=\"\" \/><\/figure>\n\n\n\n<p>As you can see, the inline element is not affected by the declared width or height.<br>The HTML<code>&lt;span&gt;<\/code> element is inline by default as well as several other elements listed <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Inline_elements\">here<\/a>.&nbsp;<\/p>\n\n\n\n<h1>display:inline-block<\/h1>\n\n\n\n<p>The difference between an inline element and an inline-block element is that an inline-block element can take up specified width and height. But, it will also not start on a new line within its parent or cause a line break after it.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/m9WDuwAJnw1NxPknbFuKLq5Ajdl10d4Dm6EIvSXyKCZB8ubZfSKArF4wnhIgx7pZuMmiILiMcVv2qpT7uFD569rTmmMqHaptd8y43-06RtpFw38Dt-MaLhY8BdSswtpfhGb1HUpr\" alt=\"\" \/><\/figure>\n\n\n\n<p>As you can see, the inline-block element does not start on a new line, but it takes up the specified width and height. <\/p>\n\n\n\n<h1>display:block<\/h1>\n\n\n\n<p>Any element styled with <code>display: block<\/code> is the polar opposite of <code>display:inline<\/code>. A block element starts on a new line and occupies the available width of its parent element or its specified width.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/lWGuiuTC02e0TBlTjsw6Ch__11styHq3zxqO3XjOYzWBroyYk_sGYGFWlz-uqRD0-O0m5255cv1jdJYK269eujxoE6JARZAJFYN4w2PSIFiL6m-k0REJpLtcp3QQZ-ETVNa5Ugpu\" alt=\"\" \/><\/figure>\n\n\n\n<p>As you can see, the block element starts on a new line.<\/p>\n\n\n\n<p>The HTML [p], <code>[div<\/code>], as well as other elements listed\u00a0<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Block-level_elements#elements\" target=\"_blank\">here<\/a>\u00a0are block elements by default.\u00a0<\/p>\n\n\n<p><span style=\"color: #ff0000\">Blog Credits: Linda Ikechukwu<\/span><\/p>\n<div>\u201d Linda Ikechukwu is a Frontend Developer turned Technical Content Consultant. She enjoys strategizing on and creating content that helps tech startups connect with their target audience. \u201c<br \/><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-2189\" src=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/09\/Linda-headshot.jpeg\" alt=\"\" width=\"150\" height=\"210\" srcset=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/09\/Linda-headshot.jpeg 715w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/09\/Linda-headshot-585x819.jpeg 585w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div>","protected":false},"excerpt":{"rendered":"<p>The inline, inline-block, and block layout values are all possible values for the CSS display properties. Many newbie frontend developers usually struggle with understanding the difference between the three, and&hellip;<\/p>\n","protected":false},"author":10,"featured_media":2280,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[248,153,249,235,246,247],"better_featured_image":{"id":2280,"alt_text":"","caption":"","description":"","media_type":"image","media_details":{"width":1280,"height":853,"file":"2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements.jpg","sizes":{"thumbnail":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-150x150.jpg","width":150,"height":150,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-150x150.jpg"},"medium_large":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-768x512.jpg","width":768,"height":512,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-768x512.jpg"},"penci-full-thumb":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-1170x780.jpg","width":1170,"height":780,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-1170x780.jpg"},"penci-slider-thumb":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-1170x663.jpg","width":1170,"height":663,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-1170x663.jpg"},"penci-magazine-slider":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-780x516.jpg","width":780,"height":516,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-780x516.jpg"},"penci-slider-full-thumb":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-1280x800.jpg","width":1280,"height":800,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-1280x800.jpg"},"penci-thumb":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-585x390.jpg","width":585,"height":390,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-585x390.jpg"},"penci-masonry-thumb":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-585x390.jpg","width":585,"height":390,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-585x390.jpg"},"penci-thumb-square":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-585x585.jpg","width":585,"height":585,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-585x585.jpg"},"penci-thumb-vertical":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-480x650.jpg","width":480,"height":650,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-480x650.jpg"},"penci-thumb-small":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-263x175.jpg","width":263,"height":175,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-263x175.jpg"},"jr_insta_square":{"file":"Difference-between-inline-inline-block-and-block-layout-elements-640x640.jpg","width":640,"height":640,"mime-type":"image\/jpeg","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements-640x640.jpg"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":2278,"source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2021\/11\/Difference-between-inline-inline-block-and-block-layout-elements.jpg"},"translation":{"provider":"WPGlobus","version":"2.10.8","language":"es","enabled_languages":["en","es","de","fr","ru"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"es":{"title":false,"content":false,"excerpt":false},"de":{"title":false,"content":false,"excerpt":false},"fr":{"title":false,"content":false,"excerpt":false},"ru":{"title":false,"content":false,"excerpt":false}}},"_links":{"self":[{"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/posts\/2278"}],"collection":[{"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/comments?post=2278"}],"version-history":[{"count":5,"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/posts\/2278\/revisions"}],"predecessor-version":[{"id":2289,"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/posts\/2278\/revisions\/2289"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/media\/2280"}],"wp:attachment":[{"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/media?parent=2278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/categories?post=2278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embold.io\/es\/wp-json\/wp\/v2\/tags?post=2278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}