HTML, Alignment, and Paragraphs

In this lesson we will focus on the study of paragraphs and their respective alignment. First, it is necessary to say that a paragraph is understood as one or more lines of text; the important thing is that they are enclosed, to delimit them, between the tags that specifically regulate paragraphs.

Programmazione HTML
Programmazione HTML

The tag that controls and determines a paragraph is the p tag, which, in collaboration with the closing tag, encloses the paragraph definitions, including alignment and line breaks in a very long paragraph. Alignment is controlled by the align attribute followed by the definitions right,left e center. So, to summarize, the paragraph definition is determined by the tags and its alignment is controlled by the align attribute, which can be defined as right, left e center. But let’s get to our usual example to see the syntax of these new tags:

 

Here is my first text

 

In this example, we only used the p tags to define the paragraph. Let’s now see, still using only p, how to define two paragraphs:

if I were to write the following text

Here is my first text Here is the second text

 

this would all result in one line. However, if I were to break it like this:

 

Here is my first text

Here is the second text

 

I would divide the text, creating a line break at the preferred point. In this way, we have created two distinct paragraphs. Now, let’s use align to test paragraph alignment for the two examples:

 

Here is my first text

Here is my second text

 

In practice, we aligned the first paragraph to the left and the second to the right. Now let’s see with three paragraphs using the three alignment parameters:

 

Here is my first text

Here is my second text

Here is my second text

 

In practice, we have written three paragraphs, each defined with its own alignment. Now a valid question arises: if I need to align all three paragraphs to the left, or all to the right, or all to the center, do I need to insert the alignment definition for each p tag? The answer is….no! For these cases, which are very common, a new tag called div within which we can insert multiple paragraphs without specifying their alignment. In practice, the div tag encloses the formatting of multiple paragraphs. Here is an example to help you understand what I mean:

 

Here is my first text

Here is my second text

Here is my second text

 

As you can see, there is no need to specify the alignment for each paragraph, as the good old div takes care of it. In this lesson, you have understood even better that each individual tag can contain formatting parameters that make it, from a simple label, a very powerful tool for creating and displaying web pages. Each individual tag can be paired with a different configuration parameter, making it independent of the other tags that make up the document. Save the example provided, always as index.html. The tags to be used for text are mainly two, one for titles and one for paragraphs. For titles, the tag is used, h which, followed by a number from 1 to 6, determines the font size and therefore the emphasis of the title.

Pubblicato in

Se vuoi rimanere aggiornato su HTML, Alignment, and Paragraphs iscriviti alla nostra newsletter settimanale

Be the first to comment

Leave a Reply

Your email address will not be published.


*