DEV Community

IamArpain
IamArpain

Posted on

Create Responsive Table using HTML and CSS Only

Many website using Responsive table using HTML and CSS Only, So do you want to add responsive table to your website?

Yes!

When writing a long posts sometimes we need to use responsive table to explain things in a better way. Tables help to understand easily for the readers.

A responsive table will display its content horizontal scroll bar if the screen is too small to display the full content. Resize the browser window as per device size.

Great!

Now, time to provide you Responsive Table using HTML and CSS Only.

So let's start.

Responsive Table HTML Code

<div>
 <table class="restable">
<caption class="rescap">Simple Responsive Data Table</caption>
<tbody>
<tr>
<th class="resth">Name</th>
  <th class="resth">Score</th>   
  <th class="resth">Status</th>
  </tr>

<tr class="restr">                                      
  <td data-label="Name" class="restd">Ravi</td>
  <td data-label="Marks" class="restd">178</td>
  <td data-label="Status" class="restd">Pass</td>
  </tr>
<tr class="restr"> 
  <td data-label="Name" class="restd">Prem</td>
  <td data-label="Marks" class="restd">169</td>
  <td data-label="Status" class="restd">Pass</td>
  </tr>
<tr class="restr"> 
  <td data-label="Name" class="restd">Alex</td>
  <td data-label="Marks" class="restd">97</td>
  <td data-label="Status" class="restd">Fail</td>
  </tr>
<tr class="restr"> 
  <td data-label="Name" class="restd">Gale</td>
  <td data-label="Marks" class="restd">120</td>
  <td data-label="Status" class="restd">Pass</td>
  </tr>
</tbody></table>
</div>
Enter fullscreen mode Exit fullscreen mode

Responsive Table using Pure CSS Only

/*CSS for Responsive Table By technicalarp.com*/
  .restable
   {border-collapse:collapse;
   width:100%;
   overflow: hidden;
   }
   .rescap{
     border-left:4px solid #009879;
     padding:15px;
 font-family:georgia;
 font-weight:bold;
 font-size:20px;
 background-color:#dddddd;
 color:#990a00;
 text-align:left;
 overflow:hidden;
 margin-bottom:4px;
 width:100%;
 }
.resth{ 
    padding:12px 15px;
    background-color:#009879;
    color:#ffffff;
    font-family:georgia;
    font-size:20px;
    font-weight:bold;
    border:1px solid #dddddd;
    text-align:center;
    }
.restr{
    border:1px solid #dddddd;}
 .restd{padding:12px 15px;
    font-family:arial;
    font-size:20px;
    text-align:center;
    border:1px solid #dddddd;
    }
.restr:last-of-type{
    border-bottom: 2px solid #009879;
    }
.restr:nth-of-type(even){
    background-color: #f3f3f3;
    }
Enter fullscreen mode Exit fullscreen mode

Responsive Table using HTML and CSS Only

If the above table work for you then congrats, and if not why not try another code.

Do you Want to try 5+ Responsive Table Code?

You can find Bootstrap table code, Pure CSS code and many more visit: Add Responsive Table In Blogger

Again, Thanks for visiting. Follow for more upcoming amazing content.

See you in new valuable content.

Discussion (0)