Ask coding questions

← Back to all posts
Why doesn't this text center with the rest of the web page?
logannball (0)

This repl is an example given that shows how to add background colors to a specific part of a web page. It was weird to me that the text from the section with a background color wasn't centering with the rest of the page, so I forked it and started playing around to see if I could make it line up with everything else.

I haven't been able to get it to center, and it's really confusing me. The section with a background color is set up exactly the same as the other two sections, except that it has a class added for the background.

I've tried various ways of adding adding auto margins to that section, and all 3, and nothing changed.

Why is this one section different from the rest?

Answered by SixBeeps (5055) [earned 5 cycles]
View Answer
Comments
hotnewtop
SixBeeps (5055)

Here's your problem.

You're overriding the padding property, which is what is doing the centering.

logannball (0)

@SixBeeps

And it ended up being so simple... =.=
Thank you!