HTML

How to make Html table responsive | Making a responsive table in html

Ravindra Kumar

Lean how to make responsive tables in HTML

Making a responsive table is easy now.HTML has provided an attribute called style that is used to give style to an HTML element so you can you CSS concepts to make the table responsive and you can use both inline and external CSS. There is a property called overflow-x  in css, and you need to give value auto so the following is the full example of making an html table responsive.

Example

 

<div style="overflow-x:auto;">
  <table>
    <tr>
      <th>Your First Name</th>
      <th>Your Last Name</th>
      <th>Col 1</th>
      <th>Col 2</th>
      <th>Col 3</th>
      <th>Col 4</th>
      <th>Col 5</th>
      <th>Col 6</th>
      <th>Col 7</th>
      <th>Col 8</th>
      <th>Col 9</th>
      <th>Col 10</th>
    </tr>
    <tr>
      <td>Ram</td>
      <td>Prakash</td>
      <td>50</td>
      <td>30</td>
      <td>50</td>
      <td>50</td>
      <td>70</td>
      <td>50</td>
      <td>50</td>
      <td>10</td>
      <td>50</td>
      <td>50</td>
    </tr>
    <tr>
      <td>Kamla</td>
      <td>Vati</td>
      <td>94</td>
      <td>94</td>
      <td>54</td>
      <td>94</td>
      <td>94</td>
      <td>64</td>
      <td>94</td>
      <td>14</td>
      <td>94</td>
      <td>94</td>
    </tr>
    <tr>
      <td>Hari</td>
      <td>Singh</td>
      <td>67</td>
      <td>47</td>
      <td>67</td>
      <td>67</td>
      <td>17</td>
      <td>67</td>
      <td>67</td>
      <td>27</td>
      <td>87</td>
      <td>67</td>
    </tr>
  </table>
</div>

Output

Your First Name Your Last Name Col 1 Col 2 Col 3 Col 4 Col 5 Col 6 Col 7 Col 8 Col 9 Col 10
Ram Prakash 50 30 50 50 70 50 50 10 50 50
Kamla Vati 94 94 54 94 94 64 94 14 94 94
Hari Singh 67 47 67 67 17 67 67 27 87 67

If this table will be accessed on a large screen such as a desktop or laptop, it will not show a horizontal scroll on the screen. It will show scrolls on-screen such as mobile or any other small screen.

Ravindra Kumar

Ravindra is a passionate full stack developer and dedicated blogger with a flair for crafting user-friendly web applications and insightful articles. With expertise spanning front-end and back-end technologies, Ravindra brings ideas to life through innovative coding solutions.

Suggested Reading

How to Create Image Maps in HTML ?

Creating image link in HTML, Learn how to give multiple links in single image in HTML Suppose, You want to give a clickable link to specific part of a image that can be possible by <map> tag of HTML.You can also target multiple clickable links to a particular are of the image.so here you need […]

What is the difference between _top and _parent target attribute of <a> Tag in HTML

What is the difference between _top and _parent target attribute of <a> Tag in HTML Answer _top : If you are using nested frame then it goes to the first / top windows _parent : If you are using nested frame then it goes to the parent / above windows on which you clicked the […]

How to Design Stylish Forms in HTML

In this post, i am going to explain that how can we design a stylish HTML form for our website and this form will be good looking.I am going to use HTML,CSS, Jquery and bootstrape in this example. First, You need to have a index.html file to design the input fields and i am going […]

How to designing responsive Navigation bar using HTML and CSS

Every website needs Navigation bar to navigate on the website properly and this is very usefull for users as well.If a website does not have good navigation interface, users prefer to leave this type of website immediately. index.html <!DOCTYPE html> <html lang="en"> <head> <title>Menu Tutorial</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="style.css"/> <link […]

What is initial-scale=1.0

The initial-scale=1.0 is a setting used within the HTML <meta> viewport tag. It controls the initial zoom level of a webpage when it’s first loaded on a mobile device or a responsive screen. <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> Meaning of initial-scale=1.0: initial-scale=1.0 sets the zoom level to 100% when the page first loads. A value of […]

How to make sticky header using HTML and CSS

Creating a sticky header using HTML and CSS is straightforward. A sticky header remains visible at the top of the viewport as the user scrolls down the page. You can achieve this using the position: sticky property in CSS. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Sticky Header</title> <link rel="stylesheet" href="styles.css"> […]