How to center an entire website?

Hey, it's my first time here. I want to code a blog like website and I want to keep everything in the center, I also want it to be responsive. currently I have nothing in the HTML other than the default stuff, but I'm trying this:
body {
margin: 0 auto;
max-width: 65%;
}
body {
margin: 0 auto;
max-width: 65%;
}
However, I don't know if styling the body is the best option
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Tenkes
Tenkes2y ago
you would probably create a class which you will add to elements that are wrapping your section. for example if you had something like this:
.container {
max-width: 60rem;
padding-inline: 1rem;
/* newer way:
width: min(60rem, 100% - 2rem); */
margin-inline: auto;
}
.container {
max-width: 60rem;
padding-inline: 1rem;
/* newer way:
width: min(60rem, 100% - 2rem); */
margin-inline: auto;
}
then you'd add that class to elements such as header, main, section etc... section elements - often called containers.
Want results from more Discord servers?
Add your server