2

Possible Duplicate:
'content' attribute to inherit node value

I know you can access the content of an element's attribute like this:

a[href]:after { content: " (" attr(href) ")"; }

Is there a way to access the actual textual content of the element? What I need to do is make an <h2> on the page appear as if it's duplicated (for styling purposes) without actually having it duplicated in the markup.

I can't pull this off with a simple text-shadow because I need this duplicated version to appear behind an image while the original appears above.

Community
  • 1
  • 1
Brandon Durham
  • 7,096
  • 13
  • 64
  • 101
  • why the restriction on the markup? I can't think of a reason that coud possibly require that no additional markup is added - after all it costs nothing. Curious to know why that's all. – T9b Sep 09 '11 at 13:50
  • It doesn't cost nothing. It costs a few extra characters. – BoltClock Sep 09 '11 at 13:51
  • My answer in the linked question might be good enough. Yes, the text is duplicated, but at least it's only in an attribute and not another element. I'm guessing you don't want to duplicate it for semantic reasons, or maybe "SEO purposes"? – thirtydot Sep 09 '11 at 13:51
  • Right. Semantically speaking, it's a bad idea to have duplicate content in the markup for the sole purpose of styling. – Brandon Durham Sep 09 '11 at 15:52
  • @thirtydot - If you put that as an answer I'll mark it. – Brandon Durham Sep 09 '11 at 15:52

1 Answers1

0

The following may help

E::first-line   the first formatted line of an E element
E::before           generated content before an E element
E::after            generated content after an E element

However I beleive what you want to do can be done by z-index and position:relative or position:absolute. Use js to duplicate the h2 tag and add a class to position it behind the image.