The following article provides an outline for Vertical Table HTML. In HTML Table, each new record is inserted as rows and columns in the Database. Rows are considered as Horizontal, and Columns are Vertical in DB. HTML tables are really used to present in information for a framework like Bootstrap; we are able to enhance the look and feel of the table easily. Tables are used for the majority of apps like web, desktop or mobile applications; also it’s important for providing information to the end-users. Using the bootstrap framework and lots of other features for delivering the functions of styling and optimizing the presentation for different elements like tables.
In general we have create a table with the help of
, | tags. In that |
---|---|
specifies the table headers, | it specifies the values in HTML. We have seen some examples below:
Example #1Code: <!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; text-align: left; } </style> </head> <body> <table style="width:75%"> <tr> <th>Name:</th> <td>Sivaraman</td> </tr> <tr> <th>Mobile:</th> <td>123456789</td> </tr> <tr> </table> </body> </html> Copy after login Output: In the above example, we have seen two headings shown on the vertical side; they are displayed in the column format. It is one of the basic examples of vertical data display in the HTML tables. Example #2Code: <html> <head> <style> table { border-collapse: collapse; } th, td { border: 1px solid #c6c7cc; padding: 10px 15px; } th { font-weight: bold; } table.scroll { width: 716px; /* 140px * 5 column + 16px scrollbar width */ border-spacing: 0; border: 2px solid black; } table.scroll tbody, table.scroll thead tr { display: block; } table.scroll tbody { height: 100px; overflow-y: auto; overflow-x: hidden; } table.scroll tbody td, table.scroll thead th { width: 140px; border-right: 1px solid black; } table.scroll thead th:last-child { width: 156px; /* 140px + 16px scrollbar width */ } thead tr th { height: 30px; line-height: 30px; /*text-align: left;*/ } tbody { border-top: 2px solid black; } tbody td:last-child, thead th:last-child { border-right: none !important; } </style> </head> <table class="scroll"> <thead> <tr> <th scope="col" colspan="1">ID</th> <th scope="col">Name</th> <th scope="col">Age</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Siva</td> <td>30</td> </tr> <tr> <td>2</td> <td>Raman</td> <td>29</td> </tr> <tr> <td>3</td> <td>Sivaraman</td> <td>31</td> </tr> </tbody> </table> </html> Copy after login Output: In the above example, we will use the scroll options. In default vertical scroll option is enabled for table data. We also enabled horizontal scroll options if it is needed. Example #3Code: <style> table { border-collapse: separate; line-height:25px; } tr { display: block; float: left; width:200px;} th, td { display: block; } </style> <form > <table border="1" class="variant-table" > <tr> <td style="background-color: #53B3AE;">Name</td> <td style="background-color: #53B3AE;">Number</td> <td style="background-color: #53B3AE;">Age</td> <td style="background-color: #53B3AE;">ID</td> </tr> </table> </form> Copy after login Output: In the above example, we have highlighted the columns using the background-color style. We also use the foreground color also for highlighting the portions as if needed. Tables in different sectionsWe have also used a different set of table formatting in HTML tables. In the above examples, we have used basics for the vertical table alignments; we have a different set of formatting for highlighted the tables: Borders and Rules: Using Borders, it will highlight the frames around the tables. <TABLE border="1" summary="Welcome to My Domain."> <CAPTION>IT</CAPTION> <TR> <TH>Name</TH> <TH>Age</TH> <TH>Number</TH> <TR> <TD>Sivaraman</TD> <TD>30</TD> <TD>8220244056</TD> <TR> <TD>Raman</TD> <TD>31</TD> <TD>123456789</TD> </TABLE> Copy after login We have seen the borders for the above examples; it’s a ruled border; we also use some other borders like Dotted-line, etc. How to Center an Image Vertically in HTML?We also align the images vertically for HTML; using CSS style, we have to assign the settings in the style tag, and we displayed the image in vertical mode. Code: <html> <body bgcolor="#ffffff"> <center> <table width="100%" height="100%" bgcolor="#a3ddc4"> <tr> <td align="center"> <table width="800" height="500" bgcolor="#ff6f6f"> <tr> <td> </td> </tr> </table> </td> </tr> </table> <!-- For Internet Explorer 3--> <center> </body> </html> Copy after login Output: The above example shows the image is in vertical mode; we also change the orientation if it’s needed. Using vertical mode space will be reduced, and the other contents of the page are shown in a single page itself compared to horizontal mode. Outer HTML tables make web browser area, except for borders, an Html table, and the whole area will be HTML table cells. The outer and inner HTML table cells inherit the default value for aligning the attributes from its parent and child table rows. It also rows the default value to use the valign attributes in the outer HTML table using |