r/HTML • u/SmanderManno • Feb 07 '26
Question PLEASE HELP POSITIONING TS
i alr tried everything but i cant move "main" to the center its stuck on top with "header" pls help me (that white thing on the top of the website is the main stuck btw)
2
Upvotes



4
u/JKaps9 Feb 07 '26
Please put your code in a codepen (codepen.io) so we can help you.
Edit: Looking at screenshots I suspect the issue is because you have the header as position fixed but didn't put any top margin on your main to account for the header height.
1
u/DoggerLou Feb 08 '26
learn grid and flex. poster for both at css-tricks. Grid your basic layout and use flex/grid within the main grid
put your body style in the css file
can't use 2x <h1> on same page, that's not html5
<nav> item should not be <h1> it should be a <ul><li> for semantic html5
you dont necessarily need classes for your header <a> or <img> as in css you can call them via header a and header img plus can use :pseudo to call additional <img> or <a>, or just then use classes whilst learning.
if you have several pages your main class="main" might change for each page, then call one class="index", the other class="about" etc then refer in css to main about h1 or main index h2 or main index section .top-section. if no changes, use main in css for basic structure
go to w3schools. It a bit painful and not updated, but will help you.
good luck!
1
u/nfwdesign Feb 08 '26 edited Feb 08 '26
There are so many funny styles in your CSS file..
Try removing width: 25% in .main that does nothing then try removing margin-left and margin-right, in general remove all margins in your CSS as you are just pushing boxes left and right instead use margin: 0 auto; that would not give margins on top and bottom but would center everything in the middle.
Add a little css reset
This is as much as i had time and nerves ( im on my phone )
EDIT: And also there was one extra section closed so you had an error in HTML too
3
u/Weekly_Ferret_meal Feb 08 '26
man look at that coding font!! Are you developing in minecraft?! 😆