brabster
brabster

Reputation: 43610

Why is my style not being applied to a non-HTML element in IE?

This doesn't work in IE6 or 7:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Title</title>
    <style type="text/css">
        N {display: block}
    </style>

</head>
<body>
    <div>
        <N>element1</N>
        <N>element2</N>
        <N>element3</N>
        <N>element4</N>
    </div>
</body>
</html>

however, it does if I replace the N tags with A tags.

Does IE have a problem with styling non-HTML tags? Or is it something else?

Upvotes: 0

Views: 160

Answers (1)

Quentin
Quentin

Reputation: 944565

Does IE have a problem with styling non-HTML tags?

Yes. It won't.

You could hack it using:

<script type="text/javascript">
document.createElement('n');
</script>

… but that won't work if JS is not available and the document is still invalid.

If no element exists that describes the semantics you want, then use the one that matches most closely (or div/span if nothing better exists) and add classes.

(Or switch to a custom XML language)

Upvotes: 7

Related Questions