

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to layout table cells, rows, and columns with JavaScript?
To layout tables correctly in JavaScript, use the tableLayout property. Set the property to fixed to set the layout.
Example
You can try to run the following code to set the way to layout table cells, rows, and columns with JavaScript −
<!DOCTYPE html> <html> <head> <style> table, td { border: 2px solid blue; } #myID { width: 100%; } </style> </head> <body> <button onclick = "display()">Set Layout Property</button> <table id = "myID"> <tr> <td>This is a text for demo</td> <td>This is another text</td> </tr> <tr> <td>One</td> <td>1</td> </tr> <tr> <td>Two</td> <td>2</td> </tr> <tr> <td>Three</td> <td>3</td> </tr> </table> <script> function display() { document.getElementById("myID").style.tableLayout = "fixed"; } </script> </body> </html>
- Related Questions & Answers
- How to add table rows Dynamically in Android Layout?
- How to set the space between cells in a table with JavaScript?
- How to multiply a matrix columns and rows with the same matrix rows and columns in R?
- How to create table rows & columns in HTML?
- How to merge table cells in HTML?
- Set width between table cells with CSS
- How to create a GridLayout with rows and columns in Java?
- Create Three Equal Columns with Bootstrap grid Layout
- Create three unequal Columns with Bootstrap grid layout
- Create two unequal columns with Bootstrap Grid Layout
- With JavaScript DOM delete rows in a table?
- How to form a two-dimensional array with given width (columns) and height (rows) in JavaScript ?
- How to display MySQL Table Name with columns?
- How to fill columns with JavaScript?
- Combine columns into rows with MySQL?
Advertisements