Let's continue learning HTML. In this lesson we will look at HTML page headers, what headers there are, how to use them correctly and when they can be used. We will also analyze the paragraphs so that you can already fill your page with text, but, most importantly, do it correctly.
If you haven't read the first article, you can find it here:
- Lesson 1. What is HTML?
Theory and practice - Paragraphs and headings of HTML pages
Today we'll talk about paragraphs and headings. Let's start with something simple - with paragraphs and where they are used.
Paragraphs per page
I will now give an example of code in which the paragraph tag will be present.
You already remember the basic structure from the first lesson. There they looked at the basics and looked at what HTML is. Therefore, let's focus our attention on what is between the tags .
When you write any text on a page, be it just a paragraph or a small explanatory line under an image, you need to place this text inside a tag.
In subsequent lessons you will see the process of formatting these paragraphs. What you should understand by now is that you cannot place a tag on a page without any tag. Because in the future it will be difficult to apply any individual styles specifically for this section of text.
Try writing a few paragraphs. Put some paragraphs in the tag, and leave others without it. And you will immediately see the difference. Because if you write a paragraph inside this tag, it will immediately have indents. Now let's move on to the HTML page headers.
HTML headers on the page
There is semantics in an HTML document. I'm not talking about HTML5 technology and its new tags. Here we will only look at the most basic ones so that you can quickly master the basics of HTML. Semantics means that you don’t need to create headings, paragraphs, tables, and so on using the same tag. This can be done, but HTML technology is more varied and for different situations appropriate tags are provided. And you just need to master the basic tags in order to freely work with HTML code.
I wrote this short introduction to the fact that for paragraphs you need to use the tag you already know. But for headings, tags that begin with the English letter “H” are used.
Here is the entire list of headers you can use:
Some of these tags are used much more often. These are tags such as h1, h2 or h3. If anyone is already familiar with CSS, then they understand that the HTML header of an h3 page can be styled in such a way that it looks similar to an h1 or h2. But the meanings they carry, at least for SEO optimization, are radically different. As a rule, these numbers, inside tags, should be understood as the level of importance of a particular HTML header. Therefore, it is necessary to carefully study these elements and then search engines people will notice your articles.
Before we get to the CSS, you'll see the default header styles in browsers. If you insert these tags one by one and write some text inside, you will see the following:
For search robots The use of headings on the page is also important. There are certain rules that you can read in our book - PDF book on website promotion.
After we have studied everything, we immediately go into the code and try to write everything ourselves. This is the fastest way to master any programming language. But HTML technology is much easier than any programming language, so anyone can figure it out. This way you will remember the tags better.
Video lesson - HTML page title? (practice)
A visual video showing an example of working with these tags:
Homework
D/Z: As an example, write a short text that will consist of 5-7 paragraphs and 2-3 different headings.
Practice more paragraphs and HTML page titles!
www.sitehere.ru
How to make a table in HTML
Any table contains rows and columns. They, in turn, can contain text and an image.
To add a table to a page, use the tag
Rows and columns are specified using tags
Table rows (
Let's create a practical table that will consist of one row and four columns. We need to mark the beginning of the table (
), end of line ( |
Result:
Now let's use the tag
Result:
I set the table width to 400 and as you can see, the first and third cells are bold and center aligned. The rest are on the left edge. I recommend that you always spend enough time formatting your code to avoid getting confused. In a small table this may not play a big role, but in a large one...
Let's talk a little more about width since I mentioned it. The width of the table is specified by the width attribute, the height - height. In this way, you can change not only the width and height of the table, but also the sizes of the cells (they all must fit into the table, otherwise the browser will not understand what you want from it).
These values (width and height) are specified in pixels, percentage. You can leave it like this, not write anything, the browser will think that you were too lazy to write “px” and will consider the number to be pixels.
Well, if you want to align the contents of one or more table cells, use the align attribute with the values left, center, right. This is horizontal alignment, but there is also vertical alignment and it has its own separate attribute - valign, which can take the following values: baseline (vertical alignment exactly along the baseline), bottom (along the bottom edge), middle (cell values will be aligned vertically in the middle), top (along the top edge). By default, browsers align cells centered (middle).
Enlarge the frame (borders) of the table and change its color
You probably noticed that I have already shown you how you can work with the frame and width of the table. In general, by default, tables are always displayed in the browser without a frame, and this is not always convenient. That's why:
Agree, somehow not very good. But this is not a problem for those who are already familiar with the HTML border attribute, which I used in the examples at the beginning of the post.
We add just 1 attribute and things get better:
![](https://i0.wp.com/seoblog.life/wp-content/uploads/5c17178ab8b295c17178ab8b78.png)
It's like Excel! Imagine if there were no lines (grid) between cells? Well, it's terrible. But what happens if you set border to 10.
As you can see, border only affects the outer border and border of the table, changing the width of the outer border, but leaving the borders between table cells the same.
Let's change the color of this frame, because there is also an attribute for this - bordercolor. Let's set its value to “d3d3d3”. Result:
How to indent a table
Indents in the table are also needed to increase readability, as are cell borders. To create indents we need the “cellspacing” attribute. I'll continue to work with our 4x4 table and apply this attribute to it. I’ll update the code for you (I’m providing only one line so as not to clutter the post):
Result:
These were the indentations on the outside of the cells. But there is a similar attribute for setting padding inside cells - cellpadding. Now I will also make it equal to 10 and you will see how the distance from the contents of the cell to its borders has increased (I had to make the number of cells smaller so that the table does not grow excessively). Code:
Result:
![](https://i0.wp.com/seoblog.life/wp-content/uploads/5c17178b480d25c17178b48120.png)
Now let’s remove “cellspacing” and leave only “cellpadding”. Result:
So we figured out how to create indents in the table and manage them. Great! If you are interested in how to do a line break, then it is written here.
How to correctly merge cells in a table
There are also special attributes for merging cells in your table. These are "colspan" and "rowspan". The first (colspan) combines cells by columns (horizontal), the second (rowspan) - by rows or vertically. Let's combine something in our table.
Be careful here! When merging cells, you need to reduce their number by the number (minus one) that you specify in the attribute parameters. If you create a table in HTML, merging cells without deleting unnecessary ones, then the site will work. We combine two - we delete one. We combine three - we remove two. And so on.
When merging cells in columns or columns, one cell must be deleted! And do this as many times as you combine cells. Now I’ll show you with an example.
When merging cells in columns or columns, one cell must be deleted! And do this as many times as you combine cells.
Now I’ll show you with an example. Here is our current table:
Let's combine cells numbered "1 and 2", "5 and 9", "4, 8, 12", "6 and 7". Look how cool it turned out, I didn’t expect it myself!
The principle of unification is this.
When horizontally merging cells number 1 and 2, you need to write “colspan=”2″” in the first one, place the contents of the second in the first (we are merging) and delete the second cell (or hide it from HTML as I did - I’ll show you later.)
When vertically merging cells number 4, 8, 12, you need to write “rowspan=”2″” in the first cell (number 4), and delete the contents of the rest, first placing them in the merged cell.
This is the code I ended up with. I've hidden the cells for clarity (to make it easier for you), but you can delete them.
I hope I explained it clearly and gave a good example.
How to make a table title
To give a table a title, use tags