Question about the Technical Documentation project's use of 'position: absolute;'

While learning I always try to understand the ‘why’ for choices and formats used. This one I’m having trouble with. In this project the example website uses a ‘position: absolute;’ for the ‘< main>’ part and I’m not sure why. They still use a ‘margin-left:’ to space it instead of using the newly acquired ‘left:’ property which isn’t available if you use the normal position value.

I tested it out without any positional property listed and just used a margin:left and it is functioning identically as far as I can tell. What am I missing?

From what I can tell, the use of absolute positioning is to wash away the body margins and the bottom margin set on main. I’m not sure why there is a bottom margin on main in the first place? Removing it doesn’t seem to have any negative consequences. And you can just set the margins on the body to 0 if you don’t want them (which a lot of CSS resets will do). But for whatever reason the person who created this decided to use absolute positioning to work around these issues.

Why this example chose to do it this way I can’t tell you. There is usually more than one way to solve a problem and this is the choice they made. Although I think the bottom margin on main may be unnecessary.

Okay that’s kind of what I wanted to hear. As a newbie I don’t want to assume it’s just another way and both are fine just to find out later that there was actually a very important reason they used ‘x’ and half my site is broken now.

When you are building these projects you should understand everything you add to your code, so you shouldn’t be running into this situation in the first place :slight_smile:

I understand what I am putting in but if mine doesn’t line up with what is provided by experts then there is probably a reason why and I should learn it. I originally assumed it had something to do with the < code> parts since I haven’t worked with them before.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.