Set display to inline table for div element in HTML and CSS

Description

The following code shows how to set display to inline table for div element.

Example


<html>
<head>
<title>Easy Clearing method </title>
<!--  w w  w . j ava 2  s  .c  om-->
<style type="text/css">
#parent1 {
border: 5px solid purple;
padding: 10px;
}

.floatleft {
border: 5px solid red;
float: left;
width: 200px;
background: white;
}

.floatright {
border: 5px solid green;
float: right;
width: 200px;
background: white;
}

.clearfix {
display: inline-table;
}
</style>
</head>

<body>
<div id="parent1" class="clearfix">
<p>This is the first parent container</p>
<p class="floatleft">This is floated content.</p>
<p class="floatright">This is floated content.</p>
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set display to inline table for div element in HTML and CSS
Home »
  HTML CSS Tutorial »
    Layout »
      Position
...
Top Align Static Block in HTML and CSS
Top offset Static Block in HTML and CSS
Align Center for static block in HTML and C...
Align Left and top for Static Block in HTML...
Align Right for static block in HTML and CS...
Bottom Align Static Block with margin-botto...
Center Static Block in HTML and CSS
Left Align Sized Static Block with margin-r...
Right align Sized Static Block in HTML and ...
Stretch Static Block right alignment in HTM...
Place Sized Relative layout block in HTML a...
Position block to the bottom right of the r...
Use negative value in left for relative pos...
Use position relative with top and left val...
Use relative position with top and left in ...
Use relative position with top and left set...
Use relative position with top and left: va...
Clear after floating element in HTML and CS...
Clear right for above float right element i...
Compare clear both with not clear elements ...
Make a new line br to clear right in HTML a...
Make element clear from the both side in HT...
Make element overlap with clear left for fl...
Do center alignment in HTML and CSS
Do Left-top Alignment in HTML and CSS
Do Right-bottom Alignment in HTML and CSS
Four column layout in HTML and CSS
Get implied width and height when all four ...
Make container grow height as child div gro...
Make div grow as children grow in HTML and ...
One column layout with header and footer in...
One column three parts layout:header, conte...
Position Image in relation to containing el...
Right-top Align and Offset in HTML and CSS
Set display to inline table for div element...
Set top to 100px in HTML and CSS
Set up four column layout in HTML and CSS
Set width for floating left and right eleme...
...