I need to implement the following markup:
The problem is that I can use only HTML+CSS and XSLT to produce it.
I thought of writing a template that would split the text into lines with XSL and print each line as a different paragraph <p>
with border-bottom
set. Is there a simpler way to achieve this by means of HTML+CSS?
A small update: The point here is to have this underline extend past the text and take all the available width. So all lines are of the same length (like lines in a copybook), except the first one which may be shorter
HTML
CSS
Live Sample
Make a div around the content for which you want that formatting and use that div inside a CSS to make necesssary formatting.
Probably won't get any better than this with pure markup: jsfiddle demo.
EDIT
Update based on the questionaire's comment:
Preview:
You don’t actually need each line to be in its own HTML element to have a bottom border. You can apply borders to inline elements, and the border will be applied to each line in the element.
In order to make the strike-through colour be different from the text colour, you need an additional HTML element in there as well. (Although Firefox has implemented
-moz-text-decoration-color
.)HTML
CSS
You can use an inline element such as
<span>
which will treatborder-bottom
like underline:and CSS:
Demo here.
Result using the markup above:
EDIT:
1.
Extending @aefxx's answer, if you can use CSS3 try this:
Demo here - this will only work in the latest browsers including Firefox and Chrome.
Result in Chrome:
2.
If you're happy with justified text:
Demo here. There are some issues with line-height but should be easy to figure out.
Result in Chrome:
Other than that, I'm afraid you might have to wrap your lines in some containers.