+ 1

How could I align the whole <body> of an html page to the center?

29th Apr 2018, 7:46 AM
Nahi Bul
Nahi Bul - avatar
7 Réponses
+ 3
Sure by applying margin hack (remember to set your desidered width else it dont work) body{ width: 80%; margin: 0 auto; }
29th Apr 2018, 8:19 AM
KrOW
KrOW - avatar
+ 3
Jemuel Stanley Warn that align attribute is NOT SUPPORTED in HTML5
29th Apr 2018, 10:05 AM
KrOW
KrOW - avatar
+ 2
👍👍👍👍
29th Apr 2018, 8:21 AM
KrOW
KrOW - avatar
+ 2
You can just use the attribute of the body tag : align <body align=centre> -Note: HTML5 doesnt support it. ........ </body> Just use <script> body { text-align: middle; vertical-align: center; margin: auto; } This is the most appropriate. KrOW width doesnt help for all screen sizes.
29th Apr 2018, 8:27 AM
Jemuel Stanley
Jemuel Stanley - avatar
+ 1
This aligns the contents inside. I want to align the "entire body".
29th Apr 2018, 7:51 AM
Nahi Bul
Nahi Bul - avatar
+ 1
KrOW thank you sooo much :)
29th Apr 2018, 8:20 AM
Nahi Bul
Nahi Bul - avatar
0
Point taken KrOW! Thank you!
29th Apr 2018, 10:24 AM
Jemuel Stanley
Jemuel Stanley - avatar