When I use a css class within a div tag it seems to ignore what is inside the css.
.centered {
background-color: red;
padding: 5px 20px 5px 20px;
}
<div style="text-align:center" class="centered">
I am centered with bg around me
</div>
When is use the same class with a span
tag nested within the div
element it does what I want.
<div style="text-align:center">
<span class="centered">I am centered with bg around me</span>
</div>
Why is this? What makes the difference?