My code is consisted of a table inside a div

If there is a reason to put the element in a container you should, but it is not always a necessity to wrap your elements in a div.

Relative can offset an element from its original position, but it retains its space in the flow where it originally was. Absolute removes an element from the flow, so it takes no space. If the parent of an absolute element is relative, the element’s position will be set within its parent. If the parent is not relative, it will be positioned in the document.
Use absolute positioning only when there is a good reason for it, which is quite rare.
For the most part you should not need to alter positioning for your elements, but leave them in the natural flow of the document.
I can’t think of a case for a table needing absolute positioning.

This may help you understand more about positioning in css:-

2 Likes