Display long dynamic text into adjacent columns like newspaper layout

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.

For example If we have a long text as following :

And We want to show it into three separate adjacent columns for better readability, it can be done as follow:



And furthermore for adjacent view, we have to write this following CSS Code :

    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:

    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 selectorin 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 :



.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

  1. The column-width property specifies a suggested, optimal width for the columns.
  2. The column-count property specifies the number of columns an element should be divided into.
  3. The column-gap property specifies the gap between the columns. (e.g padding between columns)
  4. 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.
  5. The column-span property specifies how many columns an element should span across.


About AshuTomar

Ashu is a Software Consultant at Knoldus Software LLP. she has good knowledge of HTML5, CSS3, java script, less, sass bootstarp framework. She is flexible, adaptive and self motivated personality. She have strong analytical and problem solving skills. She is highly passionate to learn and explore new technologies.
This entry was posted in CSS, HTML, JavaScript, Mobile Development, multiple column property, Scala, web application, Web Designing. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s