Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:24:14+00:00 2026-05-28T08:24:14+00:00

I’m interested how could I create a table like layout working only with div

  • 0

I’m interested how could I create a table like layout working only with div elements. I read a lot about display and float style attributes and I think this code should layout content as I want, but I see a table with the second row moved to one position below.

I expect to see:

left1 right1
left2 right2

but I see

left1 
left2 right1
      right2

Here my CSS

.big {
    display: inline-block;
}

.small {
    display: block;
}

.left {
    display: inline;
}

.right {
    display: inline;
    float: right;
}

And here my html file:

<div class="big">
<div class="small">
    <div class="left">left1</div>
    <div class="right">right1</div>
</div>
<div class="small">
    <div class="left">left2</div>
    <div class="right">right2</div>
</div>

I managed to create the table (add rule width: 100px to the .small selector) but I don’t want to specify width of my DIV elements, because they could have different width.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:24:14+00:00Added an answer on May 28, 2026 at 8:24 am

    If it’s a true table layout, it’s appropriate to use an html table. If it is not a true table layout, here’s what you need in your CSS if you were to keep the HTML unchanged:

    .small {float:left; clear: both;}
    .left {float:left: clear: both;}
    .right {float:left;}
    

    “clear: both” is sort of like a carriage return (ding! for all you with memory of typewriters)
    “float:left” puts stuff next to each other horizontally instead of the natural vertical stacking of box elements (like divs).

    For my own table-ish CSS layouts, I use only two classes, “row” and “column”, as follows:

    /* Standard CSS for div tables.  By Tom Haws
     * Overview:
     * 1. a row is a box element that wants all its children to be
     *    arranged in a (horizontal) row
     *    and is itself a new line rather than a continuation of a line.
     * 2. a column is a box element that wants all its children to be
     *    arranged in a (vertical) column
     *    and is itself a continuation of a line unless it is 
     *    the first column in a row.
     * 
     * */
    /* Any child of a row AND any column class that is anything but first-child 
     * represents another column continuing the same row 
     * */
    .row>*, .column
    {
        float: left;
    }
    /* Every first child of a row and every column that is a first child of any parent 
     * represents a new row (first column) 
     * */
    .row>*:first-child, .column:first-child 
    {
        clear: both; 
        float: left;
    }
    /* All rows and all children of a column are a new line.
     * */
    .row, .column>*
    {
        clear: both;
        float: left;
    
    }
    

    Here’s how I’d do your little example:

    <div class="row">
        <div>left1</div>
        <div>right1</div>
    </div>
    <div class="row">
        <div>left2</div>
        <div>right2</div>
    </div>
    

    Feel free to ask any follow-ups about the nuances of the CSS markup and what it’s doing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.