Search code examples
cssescapingpre

Can I have elements inside a pre?


I want to change the color of a single piece of text inside a <pre>. But I do NOT want to change the color of the whole text

I am aware I can style the <pre> like:

pre{
    ...
}

But that will apply it to the entire text :(

Can I somehow escape a <span> and place it inside the <pre> so I can do something like:

pre span{
    ...
}

If not, what other options do I have?


Solution

  • From what I read i think you are looking for something like this. http://jsfiddle.net/3guQ7/

    pre span{
        color: green;        
    }
    <div>
    <pre>
        In not Green
        <span>Im green</span>
    </pre>
    <div>