Igor G
Igor G

Reputation: 2471

Can ">" be replaced with ">" in CSS selectors?

Supposing, I have two HTML documents with an inline stylesheet introduced via <style> tag. The first one uses the 'greater-than' character in a selector:

<html>
    .......
    <style type="text/css">
        .outer > .inner
        {
            background-color: red;
        }
    </style>
    .......
</html>

While the second document uses '&gt;' entity:

<html>
    .......
    <style type="text/css">
        .outer &gt; .inner
        {
            background-color: red;
        }
    </style>
    .......
</html>

Is the second document valid? Should I expect the browsers to display it correctly?

Transformation of > into &gt; entity isn't intentional. It seems to be a side effect of nesting a stylesheet in a Confluence macro, and I'm trying to figure out whether such transformation is allowed or is it a bug.

Upvotes: 0

Views: 310

Answers (1)

Asteroids With Wings
Asteroids With Wings

Reputation: 17464

No, it can't:

A style attribute in HTML can represent characters using numeric or named character references or CSS escapes. On the other hand, the style element in HTML can contain neither numeric nor named character references, and the same applies to an external style sheet.

Because there is a tendency to want to move styles declared in attributes to the style element or an external style sheet (for example, this might be done automatically using an application or script), it is safest to use only CSS escapes.

Upvotes: 2

Related Questions