

In the above example, the header is represented by the name of the months, the part with the figures of both sales and profit represents the table body, and finally the part with the statement represents the footer of our table.Īnother important thing to note is that a table can have more than one body part. - creates a separete footer for the table.- provides a separate haeder for the table.In a table they are divided by using attributes namely: Just like how a website or any other document has three main sections – the header, body, and footer – so does a table.
#Simple css table examples how to#
How to Add a Table Header, Body, & Footer in HTML Tables When using the attributes colspan and rowspan, make sure to declare the values assigned correclty to avoid overlapping of cells. We have managed to apply the span both vertically and horizontally. In the example above, we have a cell spanning of 2 cells in the rows and 3 cells in the column as indicated. The two attributes are assigned numbers greater that zero which shows the number of cells you wish to span. The same features can be applied in an HTML table by using two cell attributes, colspan for horizontal spanning and rowspan for vertical spanning. If you worked in programs like MS office or Excel you have probably used the function by highlighting the cells and clicking the command, and voilà! You have it. Perhaps you have come across cells that stretch across two or more columns or rows in a table. How to Use Cell Spanning in an HTML Table You can play around by changing the attribute to see the different behaviors. In this case the headers belong to the column because it's what we set in the code. What the scope attribute has done, is that it shows whether a header cell belongs to either the column, row, or a group of both. The values col and row indicated that the header cell is providing inforamation for either the rows or columns respectively. The attribute is declared in the header cell, and it takes the values col, row, colgroup and rowgroup. The main purpose of the scope element is to show the target data so that the user does not have to rely on assumptions. I know the definition might be challenging to understand but hold on – with the help of an example you will better understand it. The scope attribute is used to define whether a specific header is intended for either a column, row, or a group of both. How to Use the Scope Attribute in HTML Tables To insert a caption into a table, use the tag. The caption can either be placed at the top of the table or the bottom and by default it will always be centered. The main use of adding a caption to table is to provide a description about the data represented in the table.

This is made possible with the use of tag. By default the text passed in the Heading is centered and Bold.Įmail the example above, we are able to tell what column contains which information. In basic designs the table heading will always take the top row, meaning we will have the declared in our first table row followed by the actual data in the table. Now that you have an understanding of what an HTML table is all about and how you can create it, let's go ahead and see how we can make use of these tags to create tables with more features.

To create a table in HTML you will need to use tags. The use of tables in the web has become more popular recently because of the amazing HTML table tags that make it easier to create and design them. In HTML, with the help of tables, you can arrange data like images, text, links and so on into rows and columns of cells. That’s why, in this article, we are going to learn how to use tables in HTML and then how to style them.īut, first things first – what is a table in HTML? What is a Table in HTML?Ī table is a representation of data arranged in rows and columns. In most cases, tables are more convenient to display large amounts of structured data nicely. Now, depending on the type of data, you can select between different representation methods using HTML elements. When you're building a project that needs to represent data visually, you will need a good way to display the information so it's easy to read and understand.
