DEV Community

Omkar Ajnadkar
Omkar Ajnadkar

Posted on • Originally published at thecodingexpress.blogspot.com on

WDS11 - HTML Tables

In the last article we learned about:

  • Floating images in HTML
  • How to create Image mapping in HTML In this article, we will start our discussion about tables in HTML. Tables are the great way to represent your information in tabular form. Following tags are used to create the table: <table> : HTML table is defined with this tag. <tr> : Each table row is defined with this tag. <th** >** : This is used for representing table headers. <td> : This tag is used for defining table data. By default HTML tables will not add any borders inside or outside of tables. To add borders use the border attribute inside <table> tag with the value equal to any integer inside quotes. You can also add the width attribute to <table> tag in percentage. You can also align particular text with align attribute. There is one more tag called <caption> which is used to give the table a name or heading which will be displayed on the table. It will be used inside <table> tag.  Let's see the example to understand this concept completely:

There may be the case when the particular cell should span normal one column. In such case, you will use attribute colspan in that cell. The value of attribute colspan will be the number of columns we want that span to that cell.

Similarly, there is rowspan attribute that is used to spread the span in multiple rows with its value equal to the number of rows we want to spread the span.

For any text you can always use attributes like align, color, background and formatting like bold, etalic or underline to customise your table. We can customise our table much more with CSS but we will do it when we will learn CSS.

That's all for today. Practice tables with various attributes and types to master in it. In the next part, we will learn about HTML lists and their types. Comment on how you think this article is, what improvements should I do and for any doubts. Share with your friends and keep coding.

Top comments (0)