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

4
  • 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 Commented Nov 6, 2012 at 11:23
  • 1
    Content does not accept HTML tags as stated here: stackoverflow.com/questions/5865937/… Commented Nov 6, 2012 at 11:24
  • Can you not include the noscript tags directly in the HTML? I don't think you can do it through CSS Commented Nov 6, 2012 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! Commented Nov 6, 2012 at 11:29

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.