ComputersProgramming

How to make a table in HTML: detailed description

Tables are one of the most important, but at the same time complex elements that must be present on web pages. With their help it is convenient to submit important and useful information in a fairly concise form. Of course, most editors in templates running on different engines allow you to automatically insert a table on a page of a site or a separate publication, but what if the design of a web resource, its pages are created from scratch? Then before the beginning wizard there can be a problem: how to make the table in HTML. Let's figure out how to create this element correctly and quickly.

Choose an editor

First of all, when you start creating a table, you should determine the editor in which you will work. Of course, the easiest way to choose the program in which you create the main code of the site. But it's best to use an old good notebook for these purposes.

You can ask why to complicate your life, because if you do everything at once in the editor, then you can see the result too, and you can also use the prompts of the program.

Yes, this is true, but when creating a table from scratch, you will not only be able to thoroughly study the very principle of its creation, but also to avoid annoying typos and errors in the main code. Sometimes it happens that the cursor accidentally moves down, and in the process of writing the code creeps in the error, which is sometimes difficult to find. When you create a table in Notepad, you can copy its cipher and insert it into the desired place.

Algorithm for creating a table

First, we will compile a short algorithm for how to make a table in HTML. This is necessary so that you understand the sequence of each step. Then we will analyze how to execute each of the items.

Let's start with the preparatory actions.

1. Draw a diagram of the table on a sheet of paper.

2. Count the number of rows and cells. If the number of the last is different - we consider for each row separately.

3. Determine the number of cells in the row-headers (for example, cells "No.", "Name", etc.).

4. We record the main parameters of the table - color, height and width, alignment of the text - in general, everything that you need.

Next, go directly to creating a table:

1. Insert the tags of the table.

2. Insert the tags of the rows based on the amount that you need.

3. In the rows, insert the tags of cells (regular and capital), also based on the amount that is written on your paper.

4. Set the parameters for the table as a whole.

5. If necessary, we set the indicators for individual cells.

6. Fill our cells with text.

Create a table

So, you chose the editor, now let's figure out how to create a table in HTML. The tag with which the table is inserted into the page code (

) is a pair, that is, our design begins with this tag, and ends with .

Inserting the tags of the table, we proceed to create rows and cells.

We note at once that these elements are also paired. The

tag specifies the rows, and
the cells.

For header cells, use the

paired element.

As already mentioned, first of all it is necessary to issue the lines, then in them to register the cells. In order not to get confused, we advise you to make either indents between each block in one or two lines, or to prescribe a new block of elements using the "Tab" key.

How can it look like? Like that: