Keep text left and middle of div, not center
I want to keep the text on the left but in the middle of the div.
<div id=sel>text goes here</div>
and my CSS for the same
sel{
text-align:left;
vertical-align:middle;
}
Characters and lines of text may vary. I am more focused on text with one line sitting on top. I don't want to use position: absolute / relative.
Appreciate all the help.
Thanks Jean
+2
a source to share
2 answers
First, the side of a note: vertical-align
only works with table cells. As a result, this problem is trivial with table cells. See Understanding Vertical Alignment or "How To (Not) To Vertically Center Content" .
Otherwise, you will need to place this content in another box, and then vertically center that box in the outer box. See Vertical Centering in CSS .
+3
a source to share