CSS Interview Questions
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



What are the pros and cons of using absolute positioning?

Absolutely positioned elements are removed from the document flow and do not flow around the content of other elements, nor does their content flow around the positioned element. An absolutely positioned element is positioned absolutely relative to it's closest ancestor that is either absolutely or relatively positioned.

If the user increases or descreases the font size, the absolutely postionied elements will not change positions. This may cause an absolutely positioned element to overlap other elements, or be overlapped by them.

Because of this, absolutely positioning should not be used for elements that may grow or shrink based on the expansion or contraction of content. However, it can be useful for placing decorations relative to a parent, such as positioning generated content to create a decorative effect.

What is the difference between display: inline; and display: inline-block;?

Both are set inline on the baseline with the natural flow of text. The difference is that width and height can be set on inline-block but are not supported on inline.