Search code examples
htmlcssnoscript

Can you style a noscript element?


Is it possible to use the noscript element in CSS selectors?

noscript p {
    font-weight: bold;
}

Solution

  • Yes! You can definitely do that.

    In fact, many (all?) browsers support targeting any arbitrary tag using CSS. "Official" tags in the HTML spec only define what a browser should do with them. But CSS is a language that targets any flavor of XML, so you can say foo {font-weight:bold;} and in most browsers, <foo> hello world </foo> will come out bold.

    As Darko Z clarifies, IE6/7 do not add arbitrary (non-standard) elements to the DOM automatically from the source; they have to be programmatically added.