How to Style this table-like structure


Tags: html,css

Problem :

I have this kind of table:

<table>
    <tr><td>Count A</td><td>12</td></tr>
    <tr><td>Count B</td><td>8</td></tr>
</table>

I'm new to CSS but from what I've read so far I'm assuming that the html should be:

<div id="counts-container">
     <div class="count">
         <div class="count-label">Count A</div><div class="count-number">12</div>
     </div>
     <div class="count">
         <div class="count-label">Count B</div><div class="count-number">8</div>
     </div>
</div>

It seems to me that I'm on the right track but I'm not sure about how to write the CSS for this html structure. Any suggestion I appreciate.


Ok, so I just want to confirm with you guys. This table should be:

<table>
    <tr><th>Count A</th><td>12</td></tr>
    <tr><th>Count B</th><td>8</td><tr>
</table>


Solution :

In your case using a <table> is ok - just structure it correctly:

<table>
    <tr><th>Count A</th><td>12</td></tr>
    <tr><th>Count B</th><td>8</td></tr>
</table>

<th> being the table header cell.

If you are confused about when to use tables and when not I suggest you to consult the specification http://www.w3.org/TR/html4/struct/tables.html


    CSS Howto..

    How to use 100% height with css

    I made a webpage but have excess white space at the bottom, how do I get rid of this?

    How to style an image created using javaScript

    How to retrieve sibling content in jquery?

    How to make the same distance between tags with only CSS?

    JQuery show delete button on appended div

    How to hide a CSS media query from print? “not” logical operator does not work

    How to animate CSS resize?

    How do I use Stylish to change the font in Google Tasks?

    Only partial image showing as my background image. How can I use CSS to get the full image as my background?

    How to change the color of the text next to an input field in an HTML form?

    How to prevent corners on CSS box-shadow?

    How can an external stylesheet be used to style Polymer 1.0 elements?

    how to set up responsive columns with pure CSS?

    How do I get a div to fill the width regardless if the brower window is shrunk?

    How to menu on one line and always in center?

    How to do this specifically things in CSS for a table

    How can I show a element on my site when hovered with only JS?

    How to display “Classic” fractions in CSS / Javascript

    how to write set of styles as a function in compass sass

    How do I position a div below an image with changing height?

    Why does first slideshow image click skip transition and go straight to image?

    Show and hide table column using jQuery

    How can I disable shrinking/resiziing images in Twitter Bootstrap?

    Using vi, how can I remove all lines that contain [searchterm]?

    How to make controlls for epub using HTML 5,JavaScript and CSS?

    How to stop floating right image inside div bleeds over in Google Chrome

    How would you style a PHP suffix with CSS?

    How to display Bootstrap button label vertically using CSS?

    How make input element take up available space next to a fixed width element?