Block-level Elements and Block Boxes in CSS

CSSWeb DevelopmentFront End Technology

Block-level elements have their CSS display property set to either ‘block’, ‘list-item’, or ‘table’ and these elements force a line break above and below themselves. Block-level boxes are generated by each block-level element which is a part of the positioning scheme as well as contains child boxes.

Block container boxes contain either block-level boxes and follow block formatting context or contain inline-level boxes and follow inline formatting context. Block boxes is a term used if block-level boxes are also block containers.

Anonymous block boxes are those boxes over which developer has no control. If an inline box contains a block box and the inline content around the block box is enclosed in an anonymous block box.


Let’s see an example for Block-level Elements and Block Boxes −

 Live Demo

<!DOCTYPE html>
<title>CSS Block-level Elements and Block Boxes</title>
form {
   margin: 0 auto;
   text-align: center;
* {
   padding: 2px;
   box-sizing: border-box;
input[type="button"] {
   border-radius: 10px;
   height: 40px;
   width: 100%;
   color: white;
   border: 4px solid black;
   background-color: #FF8A00;
   background-color: #F44336;
   background-color: #C303C3;
   background-color: #4CAF50;
   background-color: #03A9F4;
   background-color: #FEDC11;
<legend>CSS Block-level Elements and Block Boxes</legend>
<div id="container">Color Orange
<div class="child"></div>Color Red
<div class="child"></div>Color Violet
<div class="child"></div>


This will produce the following output −

Published on 07-Jan-2020 15:48:50