To set the HTML table border to a line, you can use two methods: set the border attribute through CSS, or use the HTML border="1" attribute to set the borders of all table cells to 1 pixel at the same time. Width.
HTML table border becomes a line
Question:How to change HTML table border Set to a line?
Answer:
To set the HTML table border to a line, you can use the following two methods:
Method 1: Use CSS
<code class="css">table, th, td { border: 1px solid black; }</code>
Method 2: Using HTML attributes
<code class="html"><table border="1"> <tr> <th></th> <th></th> </tr> <tr> <td></td> <td></td> </tr> </table></code>
Detailed explanation:
1px solid black
). Usage Example:
<code class="html"><!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <table> <tr> <th></th> <th></th> </tr> <tr> <td></td> <td></td> </tr> </table> </body> </html></code>
This code will create a table with all cells bordered by a 1 pixel wide black line.
The above is the detailed content of How to change the table border into a line in html. For more information, please follow other related articles on the PHP Chinese website!