Snippet
November 20, 2025, 4:53pm
1
Hello,
I’m trying to add the header tag since is semantically better, but afterwards the sticky section no longer works; doesn’t stick to the top after scrolling.
Current codepen: https://codepen.io/Snippet/pen/azNLvEa
No sure how to fix it without causing other issues.
ILM
November 20, 2025, 5:28pm
2
have you checked if this code works in a different environment?
Snippet
November 20, 2025, 6:02pm
3
Well yes, I tried in localhost with my website code and afterwards created the codepen to make sure it wasn’t a problem specific to my setup…
ILM
November 20, 2025, 6:06pm
4
main is not parent of header, so sticky is not engaged. Give the 2000px height to body in your css stylesheet instead
Snippet
November 20, 2025, 6:18pm
5
Thanks, updated the codepen accordingly, gave to body 2000px and main 1000px, not working though yet im afraid
ILM
November 20, 2025, 6:23pm
6
weird, I had tried it before suggesting and it was working, can’t make it work again tho
Snippet
November 20, 2025, 7:08pm
7
ohhh weird thing is if i give header tag say 1000px it works but affecting the overal layout…
ILM
November 20, 2025, 7:12pm
8
maybe it’s sticky inside its parent, try to remove position: relative from the header, have the body be with a big height
Snippet
November 20, 2025, 7:50pm
9
done, I was checking the overflow but all parent and sibling elemnts have vissible it seems…
pd: also maybe make a fork so that if you got it it again , it doesnt go away?
Snippet
November 20, 2025, 8:18pm
10
Ok seems like i made it with inset-inline-start and inset-block-start, if you find an even cleaner or better way (im not sure how responsive is this) let me know
Same link: https://codepen.io/Snippet/pen/azNLvEa
Update: it also works with
header {
top: -48px;
}
but I wish to use the “MENU” height instead wich is not variable as the rest of the header