Often I find myself attaching a class to an element just to give it position: relative;
so that I can position it's children using position: absolute;
Would there by anything wrong, or should I say, would anything break if I was to write:
* {
position: relative;
}
or perhaps the below example, as these are usually the only elements I require the relative positioning on:
div, navbar, footer, section, aside, header, article {
position: relative;
}
According to W3schools, all elements are position: static;
by default which is positioned according to the normal flow of the page.
"HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page."
and according to the same source, relatively positioned elements also position according to the normal flow of the page unless overridden with CSS:
"The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow."
* {position: relative;}
to save us some time / make the code less class heavy. – Apis