Often the location of the information block determines how the overall design will look. Alignment is a very important part of any layout. For the typesetter, block layout is at the heart of the design.
Elements come in many forms-block and line items. In this article we will discuss in detail all the ways of their alignment. Horizontal and vertical alignment will be described in detail.
Linear elements usually have no problem with horizontal alignment. Their position can be set through the html attribute text-align: – aligns the text to the center.
This method does not work with all elements. It can be used with paragraphs, headings, images and tables.
In addition to the attribute text-align, in html there is a special tag. It works the same way, but it’s a little outdated, so it’s better to use 1 way. Example of tag usage:
These methods are good, but alignment via css is still the higher priority option.
But do not rush to grief, there is a method that will align it through html. To do this, you have to reduce its width. Initially, its width is equal to 100% of the width of the parent element.
The effect may not be noticeable. To clearly see how it works, set the background color or make a frame for this block.
A little bit about adaptivity – don’t set the width of an element in pixels, the best option would be a percentage. That is, if the entire page is 100%, you can make the internal content equal to 80%. This is actively used on almost all modern sites.