menu search
brightness_auto
more_vert

How to create tables in HTML?

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

2 Answers

more_vert

To create table in HTML, use the <table> tag. A table consist of rows and columns, which can be set using one or more <tr>, <th>, and <td> elements. A table row is defined by the <tr> tag. To set table header, use the <th> tag. For a table cell, use the <td> tag.

Just keep in mind, table attributes such as align, bgcolor, border, cellpadding, cellspacing deprecated and isn’t supported by HTML5. Do not use them.

image

Example

You can try the following code to create a table in HTML. We’re also using the <style> tag to style the table border

<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <h1>Programming Languages</h1> <table> <tr> <th>Language</th> <th>Release Year</th> </tr> <tr> <td>Java</td> <td>1995</td> </tr> <tr> <td>Pascal</td> <td>1970</td> </tr> </table> </body> </html>

Output

image

 

 

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
more_vert

<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <h1>Programming Languages</h1> <table> <tr> <th>Language</th> <th>Release Year</th> </tr> <tr> <td>Java</td> <td>1995</td> </tr> <tr> <td>Pascal</td> <td>1970</td> </tr> </table> </body> </html>
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
eForumAfrica, where you can ask questions and receive answers from other members of the community. Find the answer to your question, help others by answering their questions.
...