ComputersSoftware

Using HTML in a table

In HTML there are so many elements, and each of them is unique in its own way. The table is a very interesting, demanded and serious object. Thanks to it you can not only provide information in a convenient form, but also build a whole frame of the site.

Previously, almost all webmasters used tables for site layout. Initially, tables for this were not invented. Therefore, to mark up a site, you need to use the block div element.

If you do not want to always be a novice, get used to doing everything right right away. This is very important in HTML. In the table you need to place only the usual information (text, links, lists, images, etc.), and not the whole site.

How to make an HTML table?

A table is a complex element, which consists of a large number of other elements. Remember that when creating cells or rows, you should always put a closing tag at once. Otherwise everything will fly away. The handler in the browser will look for the end of the element and, until it finds it, everything else will be included in the table. The result will be porridge.

If you write a website in "Notepad", then all you have to do with your hands. If in the finished editor, then there are usually buttons - "insert a table", "insert an image" and so on.

Example of the table 2 to 2.

the text of the first cell of the first line

the text of the second cell of the first line

the text of the first cell of the second line

the text of the second cell of the second line

The

and tags indicate the beginning and end of the table. The and tags are the beginning and end of the line. In one line there can be as many cells as are defined by the tags, there is an additional
and tags.

The main rule: the number of cells in each line should be the same. It's a table.

But, as in the Word and Excel editor, cells can be combined with each other.

How to merge cells in a table?

To combine, use the Colspan and Rowspan attributes. Span translates as "embrace" or "overlap". The literal meaning is to cover / cover cells / lines.

In the value of this attribute, you need to specify how many rows or cells will be blocked. The following is a good example of using both HTML attributes in a table.

In this example, on the first line, 3 cells were combined using the colspan = "3" attribute. Then the first cell of the second row was stretched into four lines. Remember that we stretch / unite only in the first cell. Its property will be extended further. Everything that goes before will not be affected.

If you have 5 cells and you want to merge from 2 to 4, you just need to specify the colspan = "3" attribute in cell number 2.

Note the cell number 9 in the figure above. There they combined both cells and lines at once. Such actions are not prohibited.

Look at another example to fix the information. Because some confuse attributes and sometimes combine strings instead of cells.

Designing tables

Take the usual, standard HTML case. The table has two rows of two cells each.

The result of the code will be as follows.

As you can see, there are no effects. You can add a frame, specify the width and height.

You can also play with the alignment. You can align both height and width.

Align for horizontal alignment, and valign for vertical alignment. Here is the result.

The align and valign attributes can be applied to the entire string. Then all the cells that are in it will be subject to these attributes.

In addition to the

and
tag. In fact, this is an analog of , but it is used only in the first line and serves as a header. By default, the text in is centered and bold.

How to connect styles to a table?

Like any HTML tags, the table can be converted through styles. You need to specify a style file in the head or Ready style (also indicated in the head).

...