I know I can use text-align: center; on the parent div to center all its child elements, but what if I don’t want all the child elements centered? I just want, say, one child element centered relative to the parent.
Say I have everything within a wrapper div. Some headers, forms, etc. But at the bottom I want to center a small line of text crediting something. How would I achieve that if its hierarchy is body > div.wrapper > div.credit?
So why you are complicating the CSS here? Simply wrap that text in a div and use
text-align: center;for that particular div and you are doneAnd if you want to declare in a CSS hierarchy manner just use this