Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to center elements in DIVs (four separate DIVs)? Re: How to center elements in DIVs (four separate DIVs)?

#110574
johnegraham2
Member

If the content of your h1 is just text, you should be able to just add the `text-align: center` to the h1 directly. Then you wouldn’t have to reset the rest of the div’s contents.

An h1 is `display: block` by default, so it should fill the width of its container. And this will center the text.

If your h1 is an image replacement, give it a fixed width with left and right margins `auto`.

Either way you wouldn’t need to set the display as `inline-block`.