Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
814 views
in Technique[技术] by (71.8m points)

css - custom tags not working in ie8

I tried making custom tags so that uses can enter text that displays something with red or bold etc when rendered as HTML for eg,

<rb>text here becomes red and bold</rb> and goes to default here

this gets rendered in a div with class 'note' and i have the following css set up

.note rb
{
    color:Red;
    font-weight:bold;
}

It works in ie9, chrome, firefox but doesnt work in ie8. How can I make it work there?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

if you don't mind a little javascript:

<!--[if lt IE 9]>
<script>
document.createElement("rb");
</script>
<![endif]-->

if you want to add several elements/tags, you can:

<!--[if lt IE 9]>
<script>
// bold, italic, underlined, striked
els = ['rb', 'ri', 'ru', 'rs'];
for(i = 0; i < els.length; i++) {
    document.createElement(els[i]);
    }
</script>
<![endif]-->

Update

Looks like ability to define custom elements is in the work (W3C Working Draft 6 June 2013)

Some projects that use this:

See also:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...