Skip to content
← Back to Community
For my website, how do I keep everything center
Profile icon
nianp

For my website, how do I keep my words and pictures center

Voters
Profile icon
VickyVicks
Profile icon
DarrenMar
Profile icon
studentAlfredAl
Profile icon
bramley
Profile icon
nianp
Comments
hotnewtop
Profile icon
[deleted]

Hi Nianp! Looks like your problem got solved. If not use:

body { text-align: center; }

If that doesn't work than use (This centers both horizontally and vertically):

body { margin: auto; }

If that doesn't work than try this (this centers only horizontally):

body { margin: 0 auto; }

Hope this helps! I've also noticed other people have said to use the

tag. Don't use this as it's deprecated and most browsers will remove support soon.

Profile icon
nianp

@johno1566 Thanks so much that really helped!

Profile icon
[deleted]

@nianp no problem! you can mark this answer as correct if you want to!

Profile icon
bramley

body {
text-align: center;
}
should work for text and images. If you're styling other elements, I'm pretty sure it's
body {
align: center;
}
but I'm not entirely sure.

Profile icon
ShoryaMalani

@bramley oops did not see your post before posting mine. that is correct though.

Profile icon
ShoryaMalani

Add
body{
text-align:center;
}
to css. that should work

Profile icon
glitchish

I'm pretty sure there is a tag made for centering:

hope that helps @ShoryaMalani

Profile icon
[deleted]

@Programmer567 center tag is removed from HTML5
Use:

<div align="center"> <element>only text</element> </div>
Profile icon
glitchish

oh, ok @Zuhdi28

Profile icon
dfnk

body {
text-align: center;
}