Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html how to make a table with multiple headers?

I want to make a table. I know how to make in html simple table. I want to have a few headers. A few types of header, similar to photo. I don't know number of it, I would count it in my program. What should I use, about what should I read?

I tried this:

<table border="1" width="100%">
<tr>
    <th>AAA1</th>
    <th>AAA2</th> 
</tr>
<tr>
    <th>KKK1</th>
    <th>KKK2</th>
    <th>KKK3</th>
    <th>KKK3</th>
</tr>

<tr>
    <th>PPP1</th>
    <th>PPP2</th>
    <th>PPP3</th>
    <th>PPP4</th>
    <th>PPP5</th>
</tr>
</table>

But I know it is too simple and will not give me something similar to picture. I read about colspan, but it will not give me a result which I want. Maybe there is a bootstrap for it?

enter image description here

like image 706
kkkkk Avatar asked Jan 14 '16 17:01

kkkkk


People also ask

How do you set a table style with multiple header rows?

To apply the header row formatting to multiple rows in the table: after the table style is applied, select the rows you want included in the "header row" and on the Table tools > Layout tab, click Repeat Header Rows. If header row is ticked in Design tab > Table style options, you will see your header row formatting.

How do I make two headers in HTML?

When using the <header> element you should always have one heading tag (<h1> - <h6>), but you can have multiple. You can also use the <hgroup> element, which I will explain later on. Lastly, you can also have other "header" relevant content such as the byline, publication date, table of contents etc.

How do you make a nested table in HTML?

To create a nested table, we need to create a table using the <table> tag. This table is known as the outer table. The second table that will be nested table is called the inner table. This table is also created using the <table> tag but there is a special thing that must be kept in mind.

How can you give column headers in a table in HTML?

To create table header in HTML, use the <th>… </th> tag. A table header tag is surrounded by the table row <tr>… </tr>.


1 Answers

You can have different headers for different rows. There is a good example on the W3 site. If you have questions about markup validity, you can use the W3 validator web page to check your HTML.

like image 178
cthrall Avatar answered Sep 19 '22 13:09

cthrall