So I have a DIV that contains some dynamic text. Let's say I know the text and font-size but I don't know the size of the DIV. I'd like the display of the text in the DIV to be intelligent enough to show indentation when text wraps.
Say my original text looked something like this:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
Instead, I want it to look like this:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
What's the best way to do this if I don't know the size of the DIV a priori? And what's the best way to do it if I do know the size?
Thanks!
If I understand what you're asking for, this works for me:
Not sure of the cross-browser support, but you could use the first-line pseudo-element:
Would be diplayed as
Hello World I'm
Jonathan
Sampson
Other than that, you could give the element left-padding, and then a negative text-indent.
This should work equally well for both variable and fixed size DIVs.
W3C says you just have to use text-indent property.
source
Use the CSS
text-indent
property: