0

I'm having difficulty in inserting html tags through CSS and for it to be interpreted as html.

I want to write <noscript><h2>Please enable javascript!</h2></noscript> after the h1 header on all pages; so I have

h1:after
{ 
content: "\003cnoscript\003e\003ch2\003ePlease enable javascript! \003c/h2\003e\003c/noscript\003e";
}

in my CSS.

Whilst this successfully writes

<noscript><h2>Please enable javascript!</h2></noscript> 

It is treated as a string literal and displays it on the page as part of the original h1 header.

For obvious reasons I cannot use javascript for this particular task :P

Stumbler
  • 2,056
  • 7
  • 35
  • 61
  • 2
    This may not be what you want, but why not just write "Please enable javascript" as a string literal, and then hide it with javascript? Should achieve the same thing – Andy Nov 06 '12 at 11:23
  • 1
    Content does not accept HTML tags as stated here: http://stackoverflow.com/questions/5865937/using-before-and-after-css-selector-to-insert-html – Neograph734 Nov 06 '12 at 11:24
  • Can you not include the `noscript` tags directly in the HTML? I don't think you can do it through CSS – Ren Nov 06 '12 at 11:24
  • @Andy : I think that will be my solution as what Neograph734 said seems to be true. Kindof wish that Google had returned that particular StackOverflow question at some point over the last hour! – Stumbler Nov 06 '12 at 11:29

1 Answers1

2

From W3 :

Generated content does not alter the document tree. In particular, it is not fed back to the document language processor (e.g., for reparsing).

Content in <noscript> is displayed only when javascript is disabled.

Pranav 웃
  • 8,469
  • 6
  • 38
  • 48