CSS layout has always been rectangular. Any smooth lines are the competence of the developer. Style rules provide enough options to give the page a sleek shape within the screen resolution. But any layout element is always a rectangle in which the layout of information is governed by CSS rules.
Indentation on all sides is important for each element of the page when it is absolutely positioned, and the indentation at the top of the CSS is especially defined, since it is important for various elements, especially lowercase ones.
Basic positioning rules
A block element has a margin rule for margins, padding for the elements inside it (padding), and border width, which can also be used.
Of particular importance is the indentation from above. CSS within a block associates indentation rules with rules that are absolutely and relatively positioned elements within that block.
The usual practice of CSS-rules: you can specify the indentation from all sides in the same way, pairwise top / bottom and right / left, or for each side separately. For instance,
- margin: 10px;
- padding: 10px20px;
- padding: 10px20px30px40px.
In the first case, the element is indented from the sides of the external container in which it is located. In the second case, the indentation at the top and bottom is 10px, on the left and right - 20px. In the third case, the sizes of the indents on all sides are indicated: top, right, bottom and left.
In all these cases, the indentation at the top of the CSS is 10 px.
Rules that change the position of elements
If the layout element is not positioned absolutely, it is located in the general order of page formation.
If you define the indentation at the top of the CSS in the scCurrInfo element, the goal will be achieved, but if at the li level, not.
In this example, the use of the padding rule: 40px; requires an adequate reduction of the width and height rules by 80px. Otherwise, the scCurrInfo block size will pop out of the outer block.
If we remove the padding rule from the scCurrInfo description, but add it with a value of 20px to the list item's style description, we get only the indentation from the top. CSS will not apply this value to other parties.
Naturally, this use of the indentation rule applies to every element li.
Common practice for formatting content
Some developers achieve perfection, page layout block elements. Apparently, this is a classic practice - start with tables and end your own educational process on blocks.
The freedom inherent in block layout is fascinating, and the developer’s imagination may not be limited to strict table rules: only rows, only cells, merging only horizontally and vertically. Nothing inherent in relational ideas.
Meanwhile, tables, in addition to obvious disadvantages, have many qualitative advantages. When creating indents on top, CSS takes into account indents on the left, on the right (bottom is a special moment). Table cell rules allow you to control alignment both vertically and horizontally. Using row styles, combining them with cell styles, you can create complex representations of the content.
The familiar presentation of the page in the form of rectangles (block layout) does not at all prevent it from being presented in the form of a table. These are also rectangles, but they are also table cells, that is, they have their own rules that complement the block rules.
Absolute positioning
Block with POSITION rule: absolute ; will be in the place set by its coordinates relative to the block in which it is located.
A characteristic feature of CSS rules is “practice is the best criterion of truth” in most cases, especially when cross-browser compatibility is required and layout is done manually, it is preferable to study full-fledged manuals using cascading style sheets.
Using tables often leads to problems in biasing the contents of cells. A similar offset within a block does not always affect all elements. By experimenting, you can achieve the desired result. A trivial task: how to remove indentation from above, CSS does not always solve in a trivial way.
In some cases, when you have to impose page elements in the bowels of any popular content management system for a site, you still need to pay attention not only to experimental practice, but also to look at the experience of colleagues.