Tag defining a group of table rows. The ALIGN and VALIGN Attributes

09.11.2015


Hello!
We continue to learn the basics of HTML. In this lesson I will tell you and show with examples how to make a table in HTML... And we will also consider how you can set the color of the table cells, how to center the table, learn how to make a table border, etc.
HTML tables are often used in HTML to list some information. Previously, tables were also used to create a skeleton of web pages:

... but that's a thing of the past, as today there are more efficient ways to wireframe a site with. I often use a table on my blog or website, for example, as in.

I think you figured out what you need to learn to create a table for.

What are the main tags of the table?

○ tag TABLE
It is the main container for creating a table, and it contains other table elements such as columns and rows.
The closing tag is required.

○ tag TR

Inside the container

……
rows are placed:

Columns are created using the tag .
The closing tag is required.

Attention: It is not possible to create a table without using all these tags.

Now let's try to use theory and create a table in practice.

The task: create a single row table with three columns.

row -1 / column 1 column 2 column 3

The task: create a table with three rows and three columns.

row -1 / column 1 column 2 column 3
row -2 / column 1 column 2 column 3
row -3 / column 1 column 2 column 3

Is everything clear to you up to this point? Who does not understand, raise your hand! Yeah, everyone understood, so let's go further.

Now let's look at the attributes for the table.

* Attributes

HTML table borders

To make the table visible, to the tag

applied attribute "border» .

If the attribute value « border» "0", the border will not be visible if not added to the tag

attribute "Border" , the border in the table will not be visible either.

HTML table borders - site

row -1 / column 1 column 2 column 3

Result:

Try changing the value in the attribute "Border" on the "ten" .

How to combine cells in a table

To combine cells in a table use attributes "Colspan" and "rowspan" to the tag < td> .

  • colspan - horizontal merging of cells;
  • rowspan - vertically merge cells.

In the values, specify how many cells you want to merge.

row 1 column 1
row 2 column 1 row 2 column 2

Result:

row 1 column 1 row 1 column 2
row 2 column 1

Result:

More complex example:

Tables in HTML - site

row -1 / column 1 column 2 column 3
row -2 / column 1 column 2 column 3 column 4

Result:

How to increase the spacing between table cells

To increase the distance between the text and the cell border, write the attribute "Cellpadding" to the tag

In the values \u200b\u200bof the "cellpadding" attribute, specify the indentation distance

row 1 column 1 column 2

Result:

To increase the spacing between cells in a table, use the attribute "Cellspacing" to the tag

In the values \u200b\u200bof the attribute "Cellspacing" specify the distance between cells

row 1 column 1 column 2

Result:

How to make HTML table background

To make the background of the HTML table use to the tag

and

such attributes:

  • BGCOLOR - background color for the entire table or for each cell separately. Color is given by code or word.
  • BACKGROUND - the background in the table is filled with a picture.
Tables in HTML - site
row -1 / column 1 column 2 column 3
row -2 / column 1 column 2 column 3 column 4

Result:

How to insert a picture into an HTML table

To insert a picture into an HTML table, between the tag

insert tag .

row 1 cell 1 cell 2

Result:

Values \u200b\u200bare specified in pixels (px) or percentage (%)

Align content in HTML table

To align content in HTML table use to tag attribute "Align" and "Valign" :

ALIGN - horizontal alignment of the content in the table.
Values:

  • left - push content to the left (default);
  • center set in the center;
  • right - push content to the right side

VALIGN - vertical alignment of the content in the table.
Values:

  • top press the content to the top;
  • bottom push the content to the bottom;
  • middle set content in the middle
text

default cell the content is aligned horizontally to the right, vertically - press to the bottom
the content is aligned horizontally to the left, vertically - press to the top the content is aligned horizontally in the center, vertically - press in the middle

Result:

How to center align HTML table

To center align the table, you need to wrap the table with the tag

:

Table code

row -1 / column 1 column 2 column 3

Additional and main tags to the table

Table for website
Title 1 Title 2
1 2

Result:

So we finished with the tables. Now you can create a table of any complexity yourself. Reinforce this lesson. Try to create any table yourself.
I look forward to seeing you in the next lesson. Subscribe to my blog updates.

Previous post
Next post

Then tables play a very important role in creating an invisible wireframe for a web page. And this will help to evenly and beautifully arrange text, menus, pictures, etc.
For a better understanding of what I'm trying to tell you, take a look at an example web page wireframe:

So, how to make a simple table in HTML?
To build a table, you need to use three tags:

TABLE this tag is needed to open the table. This is a kind of container that contains other elements. Here I bent it so that you can't figure it out without a donut. Nothing, you'll figure it out when you see an example.
End tag required.

The table consists of a row

row 1 row 1
row 2 row 2
row 3 row 3
cell 1 cell 2
cell 1 cell 2
cell 1 cell 2

TR creates a new table row. End tag required.

TD creates a new cell in the row. End tag required.

Let's take a look at an example to better understand all of the above:

HTML tables

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2
row 3 cell 1 row 3 cell 2

Here's the result:

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2
row 3 cell 1 row 3 cell 2

Let me explain everything.
Every time a new table is created, a tag opens.

.
Next, we place it in the middle of the container.
tag , which indicates the beginning of a new series.
In this row, insert two cells with content using the tag

Close the row with a tag .
Opening another row with a tag
Close the row with a tag .
Open the third row with the tag and insert two cells into it again.
Close the row with a tag .
Close the table with a tag
row 1 cell1 row1 cell2
.

I think you figured it out? In case someone forgot what an attribute is borderwhich I am using along with the tag

, I remind you that this is the thickness of the frame. If in border will be set to "0", then the borders of the table will be invisible.

Check out a couple of examples created tables and you can go further:

HTML tables

row 1 cell 1
row 2 cell 1

Result:

In order to insert a picture into a table, you need to have basic basic knowledge of how to insert an image into an HTML file. I talk about this in. Now that you know the basic nuances of an image in HTML, you can try to insert a picture into a table. This can be done as follows:

in the line between tags insert an image.

HTML tables

row 1 cell 1 row 1 cell 2

Result:

row 1 cell 1 row 1 cell 2

How to combine cells in a table?

To combine cells in a table, you need to use attributes like this:
COLSPAN - determines the number of columns.
The default is 1.
ROWSPAN - determines the number of rows.
The default is 1.


merge cells in the top row using the attribute colspan :

HTML tables

row 1 cell 1 + 2
row 2 cell 1 row 2 cell 2

Result:

How do I set the size of the table?

To set the height and width of the table, use the following attributes:

WIDTH - table width. The size is set in pixels or as a percentage.
HEIGHT - table height. The size is set in pixels or as a percentage.

HTML tables

row 1 cell1row1 cell2
row 2 cell 1 row 2 cell 2

Result:

Aligning content in a table

To align content (text, images) inside the table, you can use the following attributes:

ALIGN - horizontal alignment of the content in the table.
To attribute ALIGN values \u200b\u200bare assigned: left (default), center, right.
left -
push the content to the left;
center -set in the center;
right -
push content to the right side

VALIGN - vertical alignment of the content in the table.
To attribute VALIGN values \u200b\u200bare assigned: top, bottom, middle.
top press the content to the top;
bottom push the content to the bottom;
middle set content in the middle

HTML tables

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2

Result:

How to make a table background?

You can also set the background of the table for all its cells combined, as well as for each cell separately. You can set the background with a color, or with a picture. There are two attributes for the background:

BGCOLOR - background color for the entire table or for each cell separately. Color is given by code or word.
BACKGROUND - the background in the table is filled with a picture.

Attention: if you want to set the background with a color or a background image for the entire table, the attributes must be set in the tag

... And if only to a specific cell, then the tag (Table Row) and ends with the tag... A single cell in a row is framed by a pair of tags (Table Data) or (Table Header). Tag ... End codes, and can be omitted. In this case, the end of a row or cell description is the beginning of the next row or cell, or the end of a table. End table tag
.

For a better understanding, see an example:

HTML tables

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2

Result:

Attention: if the picture is smaller in size per cell, then it will repeat until it fills the cell to the end. If the picture is larger than the cell, then the background of the image will be cropped to fit the cell size.

And finally, I'll tell you more about two useful attributes.

In case you suddenly want to increase the distance between all cells, the following attributes will help:

CELLPADDING –Distance between the frame of each cell of the html table and the content of the material in it.

HTML tables

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2

Result:

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2

CELLSPACING –Distance between the borders of neighboring cells.

HTML tables

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2

Result:

row 1 cell1 row1 cell2
row 2 cell 1 row 2 cell 2

Fuh, told!
I hope I coped with the task and explained everything that I knew about html tables... And for you, I recommend that you fix the material well.
Try to create your own table, or better a whole skeleton for a web page from an html table.
All the best to you!
Thanks for visiting my blog.

Chapter 4

HTML tables

One of the most powerful and widely used tools in HTML is tables. The notion of tabular data presentation does not need additional explanation. In HTML, tables are used not only traditionally as a method of presenting data, but also as a means of formatting Web pages. Here are examples of real-life documents in which a tabular view is a convenient way to build a document. In fig. 4.1 shows a typical example of using tables to represent numeric data broken down into rows and columns. In fig. 4.2 the use of the table serves only for the purpose of formatting the document, setting the relative position of page elements. When viewing such a document, it is not immediately clear that a table is used to build it, since the frames around its cells are not drawn.

The first version of the HTML language did not provide for special tools for displaying tables, since it was mainly intended for writing simple text. With the development of the fields of application of HTML documents, the task of presenting data, for which the presence of a number of rows and columns, is typical. At first, the creation of documents containing column-aligned data was carried out using preformatted text, inside which the necessary alignment was provided by the introduction of the required number of spaces. Recall that the text inside a pair of tags

AND
is displayed in monospaced font and all spaces and tabs are significant. The alignment work for such text was done manually, which significantly slowed down the creation of documents. Support for tabular data has become the de facto standard, since it was originally implemented in all major browsers and only after a considerable time was fixed in the HTML 3.2 specification.

Special tools for creating tables, however, do not prevent the use of preformatted text. The use of tables is not limited to data consisting of rows and columns. One of the uses is to organize the arrangement of various data on a page, which can consist of plain text, images, other tables, etc. This chapter is devoted to the rules for creating tables and examples of their use.

Rice . 4.1. Typical HTML Table Example


Rice . 4.2. Example of a table without borders

Creating Basic HTML Tables

Let us first consider the minimum set of tags and their parameters, necessary and sufficient to create simple tables, and then proceed to their detailed description.

Description of tables should be located inside the section of the document ... A document can contain an arbitrary number of tables, and tables can be nested within each other. Each table must start with the tag

and end with the tag
... Inside this pair of tags is a description of the contents of the table. Any table consists of one or more rows, each of which specifies data for individual cells.

Each line begins with the tag

and and is usually used for table header cells, and - for data cells. The difference in usage lies only in the type of font used by default to display the contents of the cells, as well as the location of the data within the cell. Contents of type cells displayed in Bold and centered (ALIGN \u003d CENTER, VALIGN \u003d MIDDLE). Cells defined by a tag by default display data aligned to the left (ALIGN \u003d LEFT) and in the middle (VALIGN \u003d MIDDLE) in the vertical direction.

Tags

and cannot appear outside the table row description
cannot be omitted.

The number of rows in the table is determined by the number of opening tags , and the number of columns is the maximum number or among all the lines. Some of the cells may not contain any data, such cells are described by a pair of the following tags in a row - , ... If one or several cells located at the end of a line do not contain data, then their description can be omitted, and the browser will automatically add the required number of empty cells. It follows that the construction of tables in which different numbers of columns of the same size are located in different lines is not allowed.

The table can have a title, which is contained in a couple of tags and... Description of the table header must be located inside the tags

and
anywhere but outside the scope of any of the tags , or ... According to the HTML language specification, the location of the title description is more strictly regulated: it must be located immediately after the tag and before the first ... We recommend that you adhere to this rule.

By default, the table header text is positioned above it (ALIGN \u003d TOP) and centered horizontally.

The listed tags can have parameters, the number and values \u200b\u200bof which are different. However, in the simplest case, tags are used without parameters, which take on default values.

This information is quite enough for building elementary tables. Let's give an example of a simple table consisting of two rows and two columns, the display of which is shown in Fig. 4.3.

An example of the simplest table

Cell 1 of row 1 Cell 2 Row 1
Cell 1 of row 2 Cell 2 Row 2


Figure: 4.Z. An example of the simplest table

View tables on a page

Let's look at the purpose of various parameters that can be used in tags describing tables.

Table header

Table header tag has the only valid parameter ALIGN, which can be TOP (header above the table) or BOTTOM (header below the table). The ALIGN parameter can be omitted, which corresponds to the value ALIGN \u003d TOP. In the horizontal direction, the table title is always centered. The table may not have a title. In most cases, plain text is used as the table heading, which is regulated by the HTML specification, but in reality, between the tags and it is permissible to write any HTML elements used in the section ... Here is an example of a table header entry:

Heading located at the bottom of the table

If this header description is added to the above example, the table will be displayed as shown in Fig. 4.4.


Figure: 4.4.Table with title

Microsoft Internet Explorer provides additional options for choosing the location of the title. The ALIGN parameter accepts LEFT, CENTER, and RIGHT values \u200b\u200bfor horizontal alignment, along with the values \u200b\u200bdescribed above. Note that this is one of the rare cases where the widely used ALIGN parameter can be used for both horizontal and vertical alignment. For example, ALIGN \u003d RIGHT will ensure that the heading is positioned to the right and above the table. If you write ALIGN \u003d BOTTOM, then, as in the above example, the title will be located below the table. However, it is not allowed to use the ALIGN parameter twice in the same header. Therefore, a special parameter for vertical alignment was additionally introduced - VALIGN, which takes the values \u200b\u200bTOP or BOTTOM. For example, for a heading at the bottom of a table, aligned to the left, the description looks like this:

Left-justified heading

The table with this description of the title in Microsoft Internet Explorer will be displayed as follows (Fig. 4.5). If this example is viewed in Netscape, the title will be placed by default, that is, above the table and in the middle horizontally.


Figure: 4.5. Horizontal alignment of the table header by Microsoft Internet Explorer

The table header horizontal alignment features are an extension of the HTML specification, are not supported by the Netscape Navigator browser, and should only be used when absolutely necessary.

Tag parameters

The main tag used when creating tables is the tag

... It can be used with a number of parameters, each of which can be omitted. Valid options vary by browser. According to the HTML spec in the tag
the following parameters can be used: BORDER, CELLSPACING, CELLPADDING, WIDTH, ALIGN. NetScape and Microsoft Internet Explorer browsers allow the HEIGHT and BGCOLOR parameters to be used in addition to the five parameters listed. Certain browsers also allow other parameters to be set. Let's look at the purpose of commonly used tag parameters
.

BORDER parameter

The BORDER parameter controls the display of a border around each cell, which essentially gives the grid lines of the table, and around the entire table. By default, no frames are drawn, and the user will see only the evenly spaced text of table cells on the screen. There are many situations where the use of tables without borders is quite justified, for example, for multi-column lists implemented using tables, or specifying the exact relative position of figures and text. However, in most cases, for the traditional use of tables, it is useful to separate the cells from each other with grid lines, which makes it easier to perceive and understand the information contained in the table.

To add frames to the table, you must include in the code

a BORDER parameter, which can be numeric.

For example,

or
.

The numerical value of the parameter determines the thickness of the border in pixels, drawn around the entire table, but this value does not affect the thickness of the borders around each cell. In the absence of a numerical value, it is usually assumed to be equal to the minimum value (1), although the style of displaying frames may differ for different browsers. The ability to independently control the display of the border around the entire table and borders around cells is not available.

An example of a table with a 10-pixel border is shown in Fig. 4.6.


Figure: 4.6.Table with a 10-pixel border

The HTML 3.0 specification did not include a value for the BORDER parameter. This is only done in HTML 3.2. For example, earlier versions of Microsoft Internet Explorer did not allow specifying a numerical value.

Note that in the absence of the BORDER parameter, the frames are not drawn, but space for them is left (this applies only to Netscape). The total size of the table in the absence or presence of the BORDER parameter does not change (the exception is the case of setting BORDER \u003d 0). Thus, the minimum distance between two adjacent cells in these cases will be equal to twice the thickness of the frame, that is, two pixels. It is possible to arrange cells as close to each other as possible by setting BORDER \u003d 0, which means no borders. Some browsers may not support setting the numerical value of the BORDER parameter, then a value equal to zero will be ignored and the table will be drawn with borders.

Here are some examples:

Netscape will render all three examples differently. Note that there is a rather unique case here where one cannot speak of a default value. The third example, where the BORDER parameter is omitted, is different from any example where this parameter is present. For Microsoft Internet Explorer, the second and third examples are identical, so the default value for the BORDER parameter is zero for this browser.

CELLSPACING parameter

Parameter notation form: CELLSPACING \u003d num, where num is the numerical value of the parameter in pixels, which cannot be omitted. The num value determines the distance between adjacent cells (more precisely, between cell frames) both horizontally and vertically. By default, the value is assumed to be two. Note that traditionally in publishing systems, adjacent table cells have a common border. In HTML tables, by default, space is left between them, as can be clearly seen in the above figure (Figure 4.6). When you set CELLSPACING \u003d 0, the borders of adjacent cells will merge and create the impression of a single grid of the table (Fig. 4.7).


Figure: 4.7.Table with CELLSPACING \u003d 0

CELLPADDING parameter

Parameter notation is similar to CELLSPACING. The num value determines the amount of free space (padding) between the cell border and the data inside the cell. By default, the value is assumed to be one. Setting the CELLPADDING parameter to zero can cause some parts of the cell text to touch its border, which does not look very aesthetically pleasing.

In fig. 4.8 shows an example of a table with CELLPADDING \u003d 10.


Figure: 4.8.Table with CELLPADDING \u003d 10

The CELLPADDING and CELLSPACING parameters are very similar to each other. For a table without borders, changing one or the other parameter leads to the same result. Both parameters affect the corresponding padding horizontally and vertically. Unfortunately, separate management of horizontal and vertical margins is done, for example, for margins from images (the HSPACE and VSPACE parameters of the tag ), not provided.

All three parameters - BORDER, CELLPADDING and CELLSPACING act independently of each other, if any of them is omitted, then its default value is taken. In particular, if all of the above parameters are omitted, then the minimum distance between data from adjacent cells will be 6 pixels (for Netscape). This value is made up of two pixels for CELLSPACING, one pixel for CELLPADDING, and one pixel for the border of each cell. The most compact table will be obtained by specifying the following description:

Only in this case will the cells be located close to each other. An example of use is a table, all cells of which contain pictures of the same size, which must be placed next to each other.

WIDTH and HEIGHT parameters

When tables are displayed, their width and height are automatically calculated by the browser and depend on many factors: the values \u200b\u200bof the parameters specified in the description of the entire document, this table, its individual rows and cells, the contents of the cells, as well as the parameters set when viewing the document in a particular browser , for example, font type and size, viewport size, etc. When displaying, table sizes are calculated automatically taking into account these factors, while an attempt is made to present the table in the most convenient form - to arrange the table so that it fits in the viewport. The general scheme of viewing large documents, as a rule, boils down to linear scrolling of the contents of the document vertically and reading the text interspersed with various tables, images, etc. This applies both to HTML documents and to ordinary documents created in any text editors ... Most text editors (such as Microsoft Word) and HTML browsers automatically format the text so (if possible) so that the lines do not exceed the width of the viewport. This avoids the need for horizontal scrolling of the document. Similar actions are taken by browsers with tables - if possible, format them so that the width of the table does not exceed the width of the viewport. It can be concluded that the width of the tables is a more important, paramount parameter, the calculation of which is performed first of all in comparison with the height.

In most cases, dynamically sizing the table will result in an aesthetically proportional image with efficient use of the actual area of \u200b\u200bthe viewport. However, it may be necessary to enforce the width or height of the table. For this purpose the WIDTH (table width) and HEIGHT (table height) parameters of the tag are used

... Notation form: WIDTH \u003d num or WIDTH \u003d num%, where num is the numerical value of the width of the entire table in pixels or as a percentage of the entire window size. Note that it is permissible to specify values \u200b\u200bgreater than 100%, although it is difficult to imagine a case where this is necessary. Example:

.

Similar parameters can be set for individual cells. Note that specifying a specific value for the parameter, for example WIDTH \u003d 200, does not mean that the table will have the specified width in any case, but only determines the recommended width, which will be maintained whenever possible. Let us explain this with examples. Suppose you have a table that, under these conditions, would have a width less than the specified one by default. In this case, the browser will increase the width of the table to the required one by proportionally expanding all columns of the table. Narrowing down the viewport will not change the width of the table and may need to scroll horizontally to view it. If the table has a default width greater than the specified one, then the browser will try to reduce its width by, firstly, reducing the width of individual columns for which the specified width is greater than the required one, and secondly, breaking the text in separate cells into several lines with increasing the height of the table. These actions may not provide the required table size, and then it will have the smallest possible width. The same actions are taken for tables with no dimensions specified when the viewport is narrowed down.

Specific algorithms for setting tables for different browsers may differ slightly.

ALIGN parameter

The given tag parameter

defines the horizontal position of the table in the viewport. Valid values \u200b\u200bare LEFT (left justified) and RIGHT (right justified). By default, tables are left aligned. Note that the valid values \u200b\u200bdo not include a typical value for the alignment parameter - CENTER. Some HTML sources cite CENTER (center) as valid in this case. This follows the HTML specification, but in practice, both Netscape Navigator and Microsoft Internet Explorer implement only two values. The fact is that the presence of the ALIGN parameter in the tag
not only determines the location of the table, but also allows text to flow around the table from the opposite side, similar to the flow of images. Text wrapping around the table from both sides is not provided in any cases. For more precise flow control, use the tag
with the CLEAR parameter in the same way as it is done for ... If the ALIGN parameter is omitted, then the space to the right and / or left of the table will always be empty regardless of its width. If the table does not require text to wrap around, then you can achieve its position in the center of the viewport. To do this, for example, you can put the entire table description inside a pair of tags
and
.

Here is an example of a table with flowing text, the display of which is shown in Fig. 4.9.

Table with text flowing around it


an adult

population of St. Petersburg

  • Abram
  • Alexander
  • Alexei
  • Albert
  • Anatoly
  • Andrei

  • Arkady
  • Boris
  • Vadim
  • Valentine
  • Valery
  • Vasiliy

  • Victor
  • Vitaly
  • Vladimir
  • Vladislav
  • Vyacheslav

  • Gennady
  • George
  • Hermann
  • Gregory
  • Dmitry

  • Evgeny
  • Efim
  • Ivan
  • Igor
  • Ilya
  • Joseph
  • Konstantin

  • a lion
  • Leonid
  • Michael
  • Nikolay
  • Oleg
  • Paul
  • Peter

  • Novel
  • Semyon
  • Sergei
  • Stanislav
  • Edward
  • Yuri
  • Jacob








  • The 43 most common names mentioned cover 92% of the sample.

    Figure: 4.9. Borderless table with flowing text

    This document consists of a borderless table with the ALIGN \u003d LEFT alignment parameter, which allows the text following the table to be positioned to the right of it. The table consists of only one row, which contains two cells. Each cell contains part of an unordered list

      ... Using a table to display a list is one way to force a list into multiple columns, which is also illustrated in this example. The text located to the right of the table may not all fit there, while it will continue after the table. Try using this example to reduce the width of the browser viewport, and at some point all the text will appear at the bottom of the table. Recall that to forcibly interrupt the flow of text along the table (for example, if the subsequent text is not logically related to the table and should be located below it), you should use the code
      with the CLEAR parameter set. For this example, you need to write
      or
      ... Some browsers allow writing the CLEAR parameter without a value, but this is not recommended. To accomplish the same task, specifying multiple line feeds
      without the CLEAR parameter (as is done in the example before the text to shift it down by several lines) or several codes for the beginning of a new paragraph

      Wrong decision.

      Let's give a slightly different example for creating such a page, the display of which is shown in Fig. 4.10.

      Table without wrapping text

      The most common male names

      adult population of St. Petersburg

    • Abram
    • Alexander
    • Alexei
    • Albert
    • Anatoly
    • Andrei

    • Arkady
    • Boris
    • Vadim
    • Valentine
    • Valery
    • Vasiliy

    • Victor
    • Vitaly
    • Vladimir
    • Vladislav
    • Vyacheslav

    • Gennady
    • George
    • Hermann
    • Gregory
    • Dmitry

    • Evgeny
    • Efim
    • Ivan
    • Igor
    • Ilya
    • Joseph
    • Konstantin

    • a lion
    • Leonid
    • Michael
    • Nikolay
    • Oleg
    • Paul
    • Peter

    • Novel
    • Semyon
    • Sergei
    • Stanislav
    • Edward
    • Yuri
    • Jacob

    • The data presented were obtained on the basis of an analysis of a representative sample containing information about 5,000 men over the age of 18 living in St. Petersburg.
      The 43 most common names mentioned cover 92% of the sample.
      The frequency of occurrence of each of the other names does not exceed 0.3%

      Figure: 4.10. A borderless table with three columns

      Unlike the previous example, there is no text flowing around the table. The entire document consists of one table with a heading, containing three cells in one row. The first two cells completely repeat the previous example. The third cell contains text that comments on the contents of the first two cells. Here there is no need to set forced text break, as described in the previous case. All text related to the table should be located inside the third cell, and the subsequent text - after the end of the description of the entire table... Both examples look the same when viewed in full screen, except for the heading, which in the first case is in the middle of the two-column list, and in the second it is in the middle of all three columns of the table. However, when the viewport is reduced in the last example, no part of the text can go below the table, thereby breaking its structure.

      Formatting data inside a table

      Each individual cell within a table can be thought of as an area for independent formatting. All the rules that govern the display of text can be used to format the text within a cell. Almost all HTML elements that can appear inside the body of the document are allowed inside the cell. , including tags that control the layout of the text -

      ,
      ,


      , header codes - from

      before

      , character formatting tags -<В>, , , , , , , tags insert graphic images , hypertext links<А> and so on. Immediately, we emphasize that the scope of the tags specified within a separate cell is limited to the boundaries of this cell, regardless of the presence of the ending tag. For example, if a text color is defined inside a cell - , then even if there is no terminating code or placing it across several cells or rows of the table, the text of the next cell will be reflected in the default color.

      The following options are available to format data within table cells.

      The alignment options for the contents of the cells are ALIGN and VALIGN. Can be used in codes , and ... The horizontal alignment parameter ALIGN can be LEFT, RIGHT and CENTER (default is LEFT for and CENTER for ). The VALIGN vertical alignment parameter can be TOP (top), BOTTOM (bottom), MIDDLE (middle), BASELINE (baseline). The default is MIDDLE. Baseline alignment ensures that the text of a single line in all cells anchors to a single line. Setting alignment options at the code level defines the alignment for all cells of a given row, while in each individual cell of the row its own parameters can be defined that override the effect of the parameters specified in .

      Here's an example of a table in which the data in the cells of the first column is aligned to the right, the second column is centered, and the third is aligned to the left (default):

      Aligning table elements

      Cell 1 Cell 2 Cell 3
      Cell 4 Cell 5 Cell 6

      The display of this example by the browser is shown in Fig. 4.11.


      Figure: 4.11.Aligning data in table cells

      The NOWRAP parameter disables the ability to automatically break cell text into lines. Can be used in codes , and ... Unjustified use of this parameter should be avoided, as it can significantly reduce the ability to dynamically resize tables and impair their perception. In most cases, it is sufficient to apply NOWRAP to individual cells that really require the prohibition of word wrapping on a new line. Wrapping of words is carried out only by the separators between words (spaces), and in some cases, to prohibit breaking the text in certain places, instead of the space character, set the code of non-breaking space (NonBreaking Space). Examples include cases where a gap is not recommended - between a numerical value and the unit of measurement of a given value; between the last name and initials. So, the text 650 km or Yeltsin B.N. it is recommended to write in the form650 km and Yeltsin B.N.

      Parameters WIDTH and HEIGHT can be used in codes and ... Their syntax is similar to the syntax of these parameters for the tag

      ... Their value determines the width or height of the cell for which these parameters are written. Values \u200b\u200bcan be specified in pixels or as a percentage of the size of the entire table. Microsoft Internet Explorer only allows the WIDTH value to be set in pixels. Since a table is a coherent structure consisting of rows and columns, setting the width for a cell affects the width of the entire column in which the cell is located, and setting the height affects the entire line. If the width value in a column is specified in only one cell, then this value becomes the width of the entire column. If there are several such indications, then the maximum value is selected. The same properties apply to strings.

      Complex tables are characterized by the need to combine several adjacent cells horizontally or vertically into one. This feature is implemented using the parameters COLSPAN (COLiimn SPANning) and ROWSPAN (ROW SPANning), set in codes

      the settings for the individual columns of this group are set. Moreover, in the tag if necessary, alignment parameters could be specified, the values \u200b\u200bof which apply to all columns of the given group. Parameter values \u200b\u200bspecified in the tag , override values \u200b\u200bfrom the tag ... Note that in the tag in this example, unlike the previous one, the SPAN parameter is missing. Here its use is meaningless, since the number of elements in the group will be determined by those following the tag tags ... Therefore, any given value of the SPAN tag parameter will be overridden.

      In fig. 4.17 shows the result of the implementation of the above code, as well as a variant of displaying such a table with the entry RULES \u003d GROUPS in the tag

      or ... Notation form: COLSPAN \u003d num, where num is a numeric value that determines how many columns to expand the current cell horizontally. The use of the ROWSPAN parameter is similar, only here you specify the number of rows that the current cell should capture vertically. By default, these parameters are set to one. Simultaneous setting of the values \u200b\u200bof both parameters for one cell is allowed. Setting the values \u200b\u200bof these parameters correctly may not be a very simple task, especially since most HTML editors allow you to visually construct with the subsequent generation of HTML codes only the simplest tables.

      In fig. 4.12 shows an example of displaying a table, obtained using the following HTML code:

      Using the COLSPAN and ROWSPAN parameters

      Cell spanning two lines Cell spanning two columns
      Cell 3 Cell 4
      Cell 5 Cell 6 Cell 7


      Figure: 4.12. Table with cells spanning multiple rows or columns

      Inattentive setting of the values \u200b\u200bof the parameters of the sliding of cells can lead to their overlapping and conflicts, in which the result is unpredictable. A typical use for extended cells is a common heading for several adjacent columns or rows.

      Here is an example of HTML code (the display of which is shown in Fig. 4.13), in which extended cells are formed incorrectly.

      Invalid use of extended cells

      Cell 1 Cell 2

      Cell 3
      (common
      Ha three
      lines)

      Cell 4Cell 5
      Cell 6 Cell 7 (spread over two columns)

      Figure: 4.13.Result of incorrect definition of extended cells (text overlay)

      The BGCOLOR parameter sets the background color for the entire table, individual rows or cells. May occur in tags

      , , does not contain any information or one or more spaces that are not treated as data. Cells containing invisible data, for example, can contain code or line feed code
      , or any text that matches the background color of the cell. If cells containing data (even if invisible) are displayed in the same way by all browsers, then empty cells will be displayed differently. The Netscape browser does not show an empty cell, that is, the location where this cell is located will be painted with the background color of the page, not the background color of the cell, unlike cells containing data. No border is drawn around empty cells. An example of a table with an empty cell is shown in Fig. 4.15.


      Figure: 4.15. Empty table cell renders differently by different browsers

      Microsoft Internet Explorer displays both cells with the background color of the cells. A browser such as NSCA Mosaic provides the user with the opportunity to determine the nature of the output of empty table cells by choosing the appropriate options. Knowledge of these features will allow you to design tables that will be displayed in a suitable way, regardless of the browser chosen by the user. In some cases, it is enough to create cells containing a single code instead of some empty cells.

      Aligning data in table columns

      A common problem when creating tables is setting alignment options for individual rows or columns. To align the contents of all cells of the current line, just set the required parameters in the code

      ... However, more often than not, it is necessary to ensure the same alignment for all items in the same column, because in most cases, the column contains homogeneous data. In earlier versions of HTML, it was suggested to use the COLSPEC parameter (COLumn SPECification) for this, which was specified in the tag
      and ... This feature is not included in the HTML specification, but it is supported by both Netscape and Microsoft Internet Explorer. The record form is the same as for the tag , namely: BGCOLOR \u003d value, where the color content in RGB format or its name is specified as the value.

      Example:

      or .

      Nested tables

      Individual table cells can contain almost any language tags and data allowed in the section document. In particular, another table can be placed inside a cell of a table. Such tables are called nested tables. The rules for their construction do not differ from the construction of tables and do not need a separate description. Just note that not all browsers that support tables correctly reflect complex tables with several levels of nesting, so use them with caution.

      Here is an example of a table using one nesting level.

      Cities of the Leningrad Region

      Cities of the Leningrad Region

      H - city population (thousand people, 1992)

      P - distance from St. Petersburg (km)

      Cities Subordinated to St. Petersburg
      TownHP
      Zelenegopsk 13.6

      50

      Kolpino144.6

      26

      Kronstadt 45.2

      48

      Lomonosov 42.0

      40

      Pavlovsk 25.4

      30

      Petrodvorets 83.8

      29

      Pushkin 95.1

      24

      Sestroretsk 34.9

      35

      All cities subordinate
      administration
      Petersburg, have
      direct city
      telephone numbers.

      Regional cities
      TownHP
      Boksitogorsk 21.6

      ALIGN \u003d RIGHT\u003e 245

      Balkhov 50.3

      ALIGN \u003d RIGHT\u003e 122

      Bcevolozhsk 32.9

      24

      Vyborg 80.9 130
      Vysotsk 1.0

      ALIGN \u003d RIGHT\u003e 159

      Gatchina 80.9 46
      Ivangorod 11.9

      ALIGN \u003d RIGHT\u003e 147

      Kamennogorsk 5.9 157
      Kingisepp 51.5

      ALIGN \u003d RIGHT\u003e 138

      Kirishi 53.8

      ALIGN \u003d RIGHT\u003e 115

      Kirovsk 23.8

      55

      Lodeinoe Pole 27.3

      ALIGN \u003d RIGHT\u003e 244

      Lyga 41.8139

      (Table continuation)
      TownHP
      Lyuban 4.7

      85

      New Ladoga 11.2

      ALIGN \u003d RIGHT\u003e 141

      Gratifying 22. 9

      ALIGN \u003d RIGHT\u003e 40

      Pikalevo 25.1

      ALIGN \u003d RIGHT\u003e 246

      Support 23.1285
      Primorsk 6.7137
      Priozersk 20.5

      ALIGN \u003d RIGHT\u003e 145

      Svetogorsk 15.8

      ALIGN \u003d RIGHT\u003e 201

      Slates 42.6

      ALIGN \u003d RIGHT\u003e 192

      Pinery 57.6

      81

      Tikhvin 72.0

      ALIGN \u003d RIGHT\u003e 200

      Tosno 33.8

      53

      W liscelbypg 12.5

      64

      Figure: 4.14.Example of nested tables

      The result of displaying this example is shown in Fig. 4.14.

      At first glance, it seems that the example does not contain tables. In fact, the entire document is a borderless table consisting of a heading and just one row containing five cells. The organization of such a table serves the sole purpose of arranging the data on the page. Inside the first cell is another table with its own title and three columns, followed by text aligned in the middle. The third and fifth cells also contain separate tables. The second and fourth cells are empty, they do not contain any data and have a single WIDTH parameter that determines its width. Their purpose is to set the indentation between the first and third, as well as the third and fifth cells in which the tables are located. This is one of the possible options for setting such an indentation. Another option is to use the CELLSPACING parameter, which determines the distance between cells, but this parameter sets both horizontal and vertical indents, which is currently not required. In addition, an empty cell with the specified width will shrink when the viewport is narrowed down, as opposed to the space specified by CELLSPACING (as will CELLPADDING). Try using this example to decrease the width of the viewport in the browser, or, which will lead to the same results, to increase the size of the font used to display the text. The distance between the tables will be reduced to zero, making it possible to see all the information simultaneously for as long as possible, however, further changes will not damage the table, but will provide the ability to horizontally scroll. According to a similar scheme, you can organize the placement of information, consisting not only of tables, but also images, fragments of text, etc.

      Features of building tables

      This section discusses some specific features of individual browsers, as well as some subtleties of building and displaying tables.

      Displaying blank cells in tables

      One of the features of the presentation of tables by different browsers is the display of empty cells. According to the language description, all browsers should pad lines with empty cells if in any line their number is set less than in other lines. In addition, cells that do not contain data can be found anywhere in the table. There is a distinction between blank cells and cells that contain invisible data. In empty cells inside a pair of tags

      and
      and determined the alignment and width of each table column. For example, setting colspec \u003d "L40 R50 C80" determined the alignment of data in cells for three columns of the table: for the first column - LEFT, for the second - RIGHT and for the third - CENTER, as well as the width of each column. As the HTML language evolved, this option was dropped and is currently not part of the language specification and is not supported by most browsers. As a result, Netscape Navigator does not have any special tools for solving this problem, and the only option is to either use the default alignment, or set the appropriate values \u200b\u200bin each cell, where necessary.

      Microsoft Internet Explorer has special tags -

      and ... These tags should appear immediately after the description
      before the first occurrence of the tag .

      Tag parameters

      and there can be SPAN, which determines the number of contiguous columns to which the parameter values \u200b\u200bapply, and ALIGN, which determines the horizontal alignment of data in all cells of the corresponding column (or columns). Valid values \u200b\u200bfor the ALIGN parameter are LEFT, RIGHT, and CENTER. The default value for SPAN is one.

      Tag

      additionally allows you to set the VALIGN parameter, which determines the vertical alignment of data in cells. Valid values \u200b\u200bfor the VALIGN parameter are MIDDLE, TOP, and BOTTOM.

      Difference between tags

      and lies in the fact that the first of them, in addition to setting the data alignment parameters for the columns, also conditionally merges several columns into a group. The effect of this combination appears when using the RULES parameter, which is described below. By default, all columns in a table are considered one group. Tag should only be used to define the alignment of data in individual columns in a group.

      Let's give an example. Suppose you want to build a table containing 6 columns, with the data in the first three of them aligned to the right, and the next three in the middle. To solve this problem, you should write the following piece of HTML code:

      (data for the table)

      The result of displaying this code is shown in Fig. 4.16.


      Figure: 4.16. Table with different data alignment options in cell groups

      Another example. Assume that in the previous table, the first two columns should be aligned to the right, and the third - in the middle, with all three columns being grouped. The next three columns must also be grouped together and have the same alignment as the first group. To solve this problem, you should write the following piece of HTML code:

      (data for the table)

      In this example, after the tag

      , from which you can see the meaning of grouping.

      Advice

      Since the scope of the tags

      and is limited to the only browser Microsoft Internet Explorer, you should use them with care. The ease of use of these tags is obvious, but in practice, most tables are built using the appropriate ALIGN alignment parameter for each table cell, where necessary, which significantly increases the size of the table source code, but allows viewing in any browser.


      Figure: 4.17. Grouped Column Table

      Setting the color of table borders

      A few more options, specific to Microsoft Internet Explorer only, allow you to select the color of the table borders - BORDERCOLOR, BORDERCOLORLIGHT and BORDERCOLORDARK. These parameters can be set in tags

      , ... The color name or its hexadecimal value can be used as a value for these parameters. The BORDERCOLOR parameter determines the color of all table border elements, and the other two parameters specify the color of the individual constituent borders, overriding the BORDERCOLOR value. The BORDERCOLORLIGHT parameter paints the left and top edges of the entire table and, accordingly, the right and bottom edges of each cell in the specified color. The second parameter BORDERCOLORDARK sets the colors of the opposite edges. Due to the combination of the action of these parameters, the table will look somewhat raised above the surface of the page or deepened. It all depends on the chosen color combination.

      Note

      The Netscape 4.x browser also supports the BORDERCOLOR parameter.

      Setting the background image for a table

      Microsoft Internet Explorer (as well as Netscape 4.x) allows the BACKGROUND parameter, which specifies the background image for a table in the same way that an entire HTML document can. This parameter can be set in tags

      , and
      , , w

      Microsoft Internet Explorer allows you to use a number of new tags to structure tables and flexibly control the rendering of frames and grid lines.

      Tags

      , and more strictly set the structure of the table description, highlighting the table header cells, the main content of the table and the final row. These tags can only appear in the description of tables within a pair of tags
      and .

      Table structuring tags

      and
      .

      Tags and are used to describe the header and footer of a table. These tags can appear in the table no more than once. The ending tag for these can be omitted. Using these tags is useful when creating large tables that extend beyond one page.

      Tag can occur multiple times in the description of the table, which requires the use of the ending tag... This tag performs logical grouping of data in the same way as the tag grouping contiguous columns.

      When using new tags, it becomes possible to more flexibly control the borders and grid lines of the table.

      Controlling the drawing of frames around the table is carried out by the FRAME tag parameter

      and table grid lines with the RULES parameter. For example, it becomes possible to draw only vertical lines between columns and, instead of a border around the entire table, give horizontal lines at the top and bottom of the table.

      The FRAME parameter can take the following values:

      • BOX or BORDER - the frame is drawn from all four sides
      • ABOVE - only from the top side
      • BELOW - only on the bottom side
      • HSIDES - the bottom and top sides are drawn
      • VSIDES - the left and right sides are drawn
      • LHS - only on the left side
      • RHS - only on the right side
      • VOID - table without outer frames

      The RULES parameter controls the drawing of the internal grid lines of the table and can take the following values:

      • ALL - all internal lines are drawn
      • GROUPS - only lines are drawn separating groups
      • ROWS - lines are drawn separating lines
      • COLS - lines are drawn separating the columns
      • NONE - internal lines are not drawn

      Example:

      .

      Note

      Drawing grid lines of the table and frames will be carried out only if the BORDER tag parameter is present

      ... If this parameter is absent or its value is zero, the grid lines and frames will be absent for any values \u200b\u200bof the FRAME and RULES parameters.

      Here is an example of a complete HTML code that creates a table using the described capabilities:

      Highlighting the title and summary line

      An example of flexible line control
      grid table

      Column heading 1 Column Header 2 Column heading 3
      DataDataData
      DataDataData
      DataDataData
      DataDataData
      DataDataData
      DataDataData
      OutcomeOutcomeOutcome


      Figure: 4.18.Flexible drawing of grid lines of the table using the Microsoft Internet Explorer browser

      In this example, which is displayed by the browser in Fig. 4.18, one of the possible options for controlling the gridlines and borders around the table is shown. A 5 pixel border is drawn around the table (BORDER \u003d S) only on the top and bottom sides (FRAME \u003d HSIDES). Gridlines are drawn inside the table to separate data groups (RULES \u003d GROUPS). Data groups are defined, firstly, by the presence of three tags , each of which declares a separate table column group. Second, the tags , and<тгоот> also divide the table data into groups, which determines the drawing of internal horizontal lines.

      Setting the number of columns in a table

      Microsoft Internet Explorer (as well as Netscape 4.x browser) allows you to specify in the tag

      the COLS parameter, the value of which determines the number of columns in the table. Writing this parameter allows you to speed up the layout of the table when displayed in a browser, since it becomes possible to determine the number of columns before the table description code is loaded. Currently, enabling this parameter does not affect the document loading progress in any way.

      Vertical alignment of tables

      Last tag parameter

      specific only to Microsoft Internet Explorer, it is VALIGN, which determines the vertical alignment of the table relative to the text. Its action is similar to that for images.

      Note

      Note that the use of one and the same parameter can differ significantly both in purpose and in possible values \u200b\u200bfor different tags, even for the same browser and within the framework of the language specification. Therefore, it is impossible to compile a summary table on the use of various parameters outside the context of their application. For example, the ALIGN parameter is used in tables only in three different ways:

      • for tag
      the ALIGN parameter can take the values \u200b\u200bLEFT or RIGHT, and means the location of the table, aligned to the left or right edge, respectively;
    • for tag
    • ,
      the ALIGN parameter takes the values \u200b\u200bTOP or BOTTOM, and means the location of the table header above or below the table;
    • for tags
    • and the ALIGN parameter takes the values \u200b\u200bLEFT, RIGHT or CENTER, and means to align the contents of the corresponding cell (or cells) in the table horizontally.

      Alternative to table view

      Support for tables has become a common feature of Web browsers, so there is little or no reason to avoid using them. Nevertheless, we will consider possible options for alternative data representations that can be used instead of tables or in addition to them.

      Some other methods that do not use the concept of tables:

      • Using preformatted text. This technique was traditionally used in early versions of HTML, when table support did not yet exist. Its use has not lost its relevance to this day, since such texts will be correctly displayed by any browsers, including purely text ones.
      • Using an image containing a table. The table can be created with any text editor or even displayed by a Web browser and then saved as a picture in one of the graphic formats. This is not the best option, as it loses all the flexibility to dynamically customize the display of tables. In addition, it becomes necessary to store an additional file with an image, the size of which will also, as a rule, be much larger than the size of the text describing the HTML table. A possible area of \u200b\u200bapplication is tables of strictly defined sizes, for which the dependence of its display on any external factors (fonts, browser operating modes, etc.) is unacceptable.
      • Using lists instead of tables. For the simplest cases, instead of organizing tables, it is quite possible to get by with one of the types of lists available in HTML.

      Preparing tables

      Any editors can be used to prepare HTML tables, most of which have tools for creating tables visually. Let's give an example of preparing a table in the HotDog Professional editor. To create a table, just select the Tables item from the Insert menu, after which the dialog box shown in Fig. 4.19. The creation of a table consists in filling in the appropriate fields in the window. After determining the number of rows and columns in the table, you can proceed to directly filling in the individual table cells, which will be shown in the same dialog box. The dialog box has a Preview button, clicking which allows you to view the resulting table using the built-in browser (Fig. 4.20).


      Figure: 4.19. Dialog box for creating tables


      Figure: 4.20. Table shown using the built-in browser

      After completing the preparation of data for the table, click the OK button. Then the generated table description code will be inserted into the edited HTML document. For the example shown in Fig. 4.19, the following code will be generated:

      (part of code omitted)

      Head of table
      Column 1 Column 2 Column 3 Column 4
      1 2 3 4

      Similarly, this task is solved using the Netscape Composer component of the Netscape Communicator program. In fig. 4.21 shows a dialog box in which you need to fill in the required fields. To enter additional tag parameters

      Extra HTML button is provided. After filling in the fields of the dialog box, you should click the Apply button and then you will be given the opportunity to fill in the table cells (Fig. 4.22).

      Figure: 4.21. Netscape Composer Table Parameters Dialog Box


      Figure: 4.22. Initial position of the input cursor in an empty table

      A task

      Create a table and specify its parameters (margins and distance between cells) through styles.

      Decision

      A table consists of rows and columns of cells that can contain text and pictures. To add a table to a web page, use the tag

      ... This element serves as a container for elements that define the contents of the table. Any table consists of rows and cells, which are set accordingly using tags and
      ... The table must contain at least one cell (example 1). Allowed instead of tag use tag ... Text in a cell decorated with a tag , displayed by the browser in bold and aligned to the center of the cell. Otherwise, the differences between cells created via tags and not.

      Example 1. Creating a table

      HTML5 IE Cr Op Sa Fx

      Table tag

      Cell 1 Cell 2
      Cell 3 Cell 4

      The order of the cells and their appearance is shown in Fig. 1.

      Figure: 1. Result of creating a table with four cells

      The border attribute of the tag

      it is allowed to add only with an empty value (
      ) or equal to 1. All other values \u200b\u200bare not validated.

      The padding style property is used to control the margins within the cells, which is added to the td selector. The spacing between cells is changed by the border-spacing property (example 2) added to the table selector, the IE browser only understands it since version 8.0.

      Example 2. Fields within cells

      HTML5 CSS 2.1 IE Cr Op Sa Fx

      Table tag

      Heading 1Heading 2
      Cell 3Cell 4

      A table with fields and spacing between cells is shown in Fig. 2. A similar result can be achieved with a white border around the cells.

      Figure: 2. Fields in table cells

      Became popular, web designers mainly used the table layout method and got very good results.


      Tags used to build a table in html

      table - required tag opening and closing the table
      caption - an optional tag denoting the title of the table
      th - an optional tag, in the opening and closing tags of which the column name is written. Typically highlighted in bold
      tr - a required tag from which the line opens and closes
      td - a required tag indicating the opening and closing of a cell in a row

      Sample code for a simple table



      Html table





      Table name

      Column 1

      Column 2

      Text in the first cell

      Text in the second cell



      The browser will display

      Purpose of tables in html

      The spreadsheet lesson is very important! Thanks to tables, you can arrange not only text, but also images, links and much more. In the table you can set background (or its color), indent, width, border and other parametersthat will give it a beautiful appearance. Table - Your first step to understanding web design! Previously, many sites were entirely laid out as tables, that is, everything that the user saw (side menu, top menu, content) was the content of cells in a large table.
      On that note, let's go directly to the attributes that make the table look beautiful ...

      Properties and parameters of html tables: indent, width, background color, border (frame)

      Have table tag there are the following attributes:

      width - table width. can be in pixels or% of the screen width.
      bgcolor - background color of table cells
      background - fills the background of the table with a picture
      border - frame and borders in the table. The thickness is specified in pixels
      cellpadding - padding in pixels between the cell content and its inner border
      As before, write the value of the attribute in quotes.

      Let's consider the application of these attributes by example. To do this, create a table (but already without the extremely rarely used caption and th tags) and set the parameter to the attribute border (border), width (width of the table, row, or cell) and bgcolor (cell color)



      Html table







      As a result, the browser will display a table of the following form

      frame - an attribute denoting a border around the table. There are the following values:

      Void - no frame,
      above - only the top frame,
      below - only the bottom border,
      hsides - top and bottom frames only,
      vsides - only left and right frames,
      lhs - left border only,
      rhs - right border only,
      box - all four parts of the box.

      rules - an attribute denoting borders within a table, between cells. There are the following values:

      None - there are no borders between cells,
      groups - borders only between row groups and column groups (will be discussed a little later),
      rows - borders only between rows,
      cols - borders only between columns,
      all - display all borders.

      Consider the example code



      Html table


      Column 1

      Column 2









      Result

      Now let's try to create a nice table. For this, let's start using alignment in the table... For this, there are the following familiar parameters:

      align - table alignment. It can be positioned to the left (left), right (right), center (center)
      cellspacing - distance between table cells. Specified in pixels (default 0 pixels)
      cellpadding - padding in pixels between the contents of the cell and its inner border (by default 0 pixels)
      Consider an example



      Html table


      Column 1

      Column 2

      Text in the first cell of the first column

      Text in the second cell of the second column







      The browser displays a centered table that looks like this

      Tr strings and td cells in HTML tables

      Let me remind you again that tables are formed line by line (tr). Rows (tr) already contain cells (td). If you set a parameter for a string (tr), then it will be valid for all cells (td) in this line, if for a specific cell, then only for it. In the examples above, I specified the color for the line, this parameter was distributed accordingly for all cells.





      For tr and td tags there are the following

      align - text alignment inside the cell. Left (left), right (right), center (center)
      valign - vertical alignment of text inside the cell. Up (top), down (bottom), center (middle)
      bgcolor - sets the line color
      width - column width (all cells below will accept this parameter) is specified in pixels or in percentage, where 100% is the width of the entire table
      height - cell height (all cells in the row will accept this parameter)

      Consider a code where the contents of the cells (td) are aligned on different edges: in the first one to the left, in the second to the right:



      Html table


      Column 1

      Column 2

      Text in the first cell of the first column

      Text in the second cell of the second column

      Column 1

      Column 2







      Result

      With the help of tables, you can make a very good page. Do not forget that you can insert not only text into cells, but also images, links, etc.!)

      Thanks for your attention! I hope the material was helpful!


      Column 1

      Column 2

      Text in the first cell of the first column

      Text in the second cell of the second column