Folks, If we have quite a long text, and we want to show it into three adjacent columns, One way to implement it via three <div>’s or <p>’s in HTML and adding CSS properties.

And We want to show it into three separate adjacent columns for better readability, it can be done as follow:
HTML:
And furthermore for adjacent view, we have to write this following CSS Code :
.main{ display:inline-block; } .first{ float: left; width: 400px; padding: 0 20px; }
To apply vertical rule between these columns so that it can have better look&feel we have to write another CSS class as follow:
.vertical-rule{ border-right: 1px solid #cccccc; }
and add it to first two divs only,
Even though with these CSS and html code we can not manage following scenario i.e
if the complete text to be displayed in P tag is rendered dynamically through a particular selector, in such case it can be complicated to measure out how this text should be break to display in 3 divs/columns.
Unfortunately this is impossible to do with CSS and HTML without forcing column breaks at fixed positions, or restricting the markup allowed in the text, or using scripting.
CSS3 introduced some new property to make such layouts, In case you have noticed in newspaper,magazines etc have block layout mode because people have trouble reading text if lines are too long, if it takes too long for the eyes to move from the end of the one line to the beginning of the next, they lose track of which line they were on.
This limitation is solved by adding new following CSS3 properties to extend the traditional block layout mode.
These properties solve the above discussed issue, the code becomes concise ,clear and easy to implement instead of using complicated structure through JS. Here all those extra static divs are removed, using only single CSS class to manipulate display of content:
Multi-column Properties
column-width
column-count
column-gap
column-rule
column-span
For the above example context We just have write the following :
HTML :
.main { column-count: 3; column-gap: 40px; column-width: 300px; } h2 { column-span: all; }
Its O/p will be
To apply vertical rule between these column, we just have to add one more css property in main class i.e. column-rule, rather than adding an extra class for this.
Let’s explain the multiple column properties
- The
column-width
property specifies a suggested, optimal width for the columns. - The
column-count
property specifies the number of columns an element should be divided into. - The
column-gap
property specifies the gap between the columns. (e.g padding between columns) - The
column-rule
property is a shorthand property for specifying color, width, and style of a vertical rule between all the columns. It displays a vertical rule between all the columns. - The
column-span
property specifies how many columns an element should span across.