Reputation: 2349
Well it should work in IE, I know IE doesnt support content property anything other that?
Upvotes: 3
Views: 18641
Reputation: 351466
The only option is the the content
property:
The content property is used with the
:before
and:after
pseudo-elements, to insert generated content.
But as you point out, this is part of CSS 3 and is not supported by IE. In the meantime you will need to compensate by using JavaScript.
Upvotes: 13
Reputation: 8312
It is quite possible to solve this without Javascript, using a combination of HTML and CSS. The trick is to duplicate the content added by the CSS in the HTML an IE-specific conditional comment (not shown by other browsers) and use the display
CSS selector to toggle when that element is shown. According to MSDN, IE 8+ supports CSS :after
and content:
, so only IE 7 and below need to use a conditional comment.
Here is an example:
<style type="test/css" media="screen">
.printonly { display: inline; }
</style>
<style type="text/css" media="print">
#maintitle:after { content:" \2014 Site Title";} /* for IE8+ and Other Browsers. sidenote: Can't use &mdash directly in generated content, so using escape code */
.printonly { display:inline } /* For IE <= 7 */
</style>
<h1 id="maintitle">Page Title
<!--[if lte IE 7]><span class="printonly">— Site Title</span><![endif]-->
</h1>
Upvotes: 2
Reputation: 4389
The only way is JavaScript, or CSS3.
Maybe you could tell us what you need to do - then we can help.
Why can't you do it with js?
Upvotes: 0
Reputation: 43243
You could try using IE8.js to fix content, which might do the trick. If not, then there's nothing you can do besides background-image's with text
Upvotes: 1