Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Styling dynamic HTML via in-component tag (Unused CSS selector)

$
0
0

I am trying to add some styling to an HTML tag rendered inside of the {@html...} tag of a Svelte component, but it appears that it only inherits the parent's styling (the container of the {@html...} tag). Moreover, the "Unused CSS selector" error pops up displaying that my styling selector for that specific HTML tag inside of the Svelte {@html...} tag merely doesn't work. Is Svelte built that way and is there a method for styling tags that are rendered inside of the Svelte {@html...} tag?

I've tried steps provided in the official Svelte tutorial, but they don't clearly show how to do it.

<style>    p{        color: red;    }    h1{        color: blue;    }</style><script>    let string = "<h1>what</h1>";   </script><p>{@html string}</p><p>no</p>

I want the h1 tag to be blue, not inherit the red color from the p tag


Viewing all articles
Browse latest Browse all 1541

Trending Articles