Prefixing HTML to element via CSS
Posted: Thu Jul 06, 2006 8:17 am
I was curious whether its possible in CSS to add a small HTML snippet before all instances of a specific element.
As an explanation, to turn:
into
using only CSS.
I played around with:
But of course is probably not the way to go (if its even possible).
The problem of course is that it's added to the start of the <pre> element and so the HTML is not being parsed by the browser. Altering the original HTML is very difficult and so I was hoping there was some way around having to go editing source code...
Any way of applying a style to a preceeding element using CSS2 selectors? Opposite of p + pre (in the case above).
As an explanation, to turn:
Code: Select all
<p>some text</p>
<pre>
public function hello() {
echo 'Hello';
}
</pre>Code: Select all
<p>some text</p>
<p><span style="font-weight: bold;">php:</span></p>
<pre>
public function hello() {
echo 'Hello';
}
</pre>I played around with:
Code: Select all
#bodyContent p + pre.php:before {
content: "<p><span style=\"font-weight: bold;\">php code:</span></p>";
}The problem of course is that it's added to the start of the <pre> element and so the HTML is not being parsed by the browser. Altering the original HTML is very difficult and so I was hoping there was some way around having to go editing source code...
Any way of applying a style to a preceeding element using CSS2 selectors? Opposite of p + pre (in the case above).