htmlcsshtml-tag-detailshtml-tag-summary

once again div vs tables




In my project, I have come across a situation where we have to create table (expandable).
I have implemented using divs and spans.
my senior is asking ti implement it using td,tr

<div class="header"><div class="colLabel" style="width: 24%;">continent</div><div class="colLabel" style="width: 24%;">country</div><div class="colLabel" style="width: 24%;">population</div><div class="colLabel" style="width: 24%;">gdp</div></div>


my implementation is http://jsfiddle.net/agasthyanavaneeth/eLf5K/6/embedded/result/
please help me
thanks :)


Solution

  • Yes use a table for tabular data rather than a generic <div>. You could also use the new HTML5 tags: <details> and <summary>

    Then do something like the following:

    <details>
       <summary>Continent name</summary>
        <p>Country, population and gdp content here</p>
    </details>
    

    http://html5doctor.com/the-details-and-summary-elements/