How to align an indented line in a span that wraps into multiple lines?
Does anyone have an idea how to align the second line?
span.info {
margin-left: 10px;
color: #b1b1b1;
font-size: 11px;
font-style: italic;
font-weight: bold;
}
<span class="info"></span>
display:block;
then you've got a block element and the margin is added to all lines.
While it's true that a span is semantically not a block element, there are cases where you don't have control of the pages DOM. This answer is inteded for those.
<span>
elements are inline elements, as such layout properties such as width
or margin
don't work. You can fix that by either changing the <span>
to a block element (such as <div>
), or by using padding instead.
Note that making a span
element a block element by adding display: block;
is redundant, as a span
is by definition a otherwise style-less inline element whereas div
is an otherwise style-less block element. So the correct solution is to use a div
instead of a block-span
.
span
is a inline element which means if you use <br/>
it'll b considered as one line anyway.
Change span
to a block element or add display:block
to your class.
http://www.jsfiddle.net/tZtpr/1/
<!DOCTYPE html>
<html>
<body>
<span style="white-space:pre-wrap;">
Line no one
Line no two
And many more line.
This is Manik
End of Line
</span>
</body>
</html>