So, I'm working on a website with a fixed header (which is used to navigate).
I use padding-top on body to lower the content to fit with the header.
This is how it looks like right now:
body
{
background-color: red;
padding-top: 50px;
}
.header {
background-color: yellow;
position: fixed;
width: 100%;
height: 50px;
top: 0;
left: 0;
}
<div class="header">
Header
</div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.<br>
Sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
My question is: What would be better to use in this situation? margin-top or padding-top?
There's no actual better way to do it. It's just to you. Maybe one will be slightly faster to render then another but nothing that someone could notice.
As a tip anyway is to make the header positioned as fixed so it scrolls down with the user.