In my javascript code, I need to put text at absolute positions on the screen, according to the top and left.
So, I put the text in a div, and instead put the div at the absolute position on the screen; BUT, that doesn't put the text into the top-left corner of the div, which I want. How do I do this?
I tried additionally wrapping the text in a span, to try to use vertical-align with that, but that doesn't work either.
.a {
position: absolute;
display: block;
background-color: red;
font-size: 50px;
color: gold;
margin: 0px;
padding: 0px;
text-align: left;
vertical-align: top;
}
.b {
background-color: blue;
vertical-align: top;
text-align: left;
margin: 0px;
padding: 0px;
}
<div class="a">
<span class="b">Put Text At Top</span>
</div>
Please note as the font size varies, I don't want to use some fixed negative margin as I read in another answer.