Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

css - Commenting out stylesheets in HTML documents to support older browsers

I've been reading some fairly old books to learn CSS. I've noticed that most of them recommend that style declarations to be written like this to remain backwards compatible with "older browsers" that don't support CSS:

<style type="text/css"><!--

(style declarations)

--></style>

So my question is, is this still a generally suggested practice (and is it still really used), considering that practically no one these days uses old browsers that can't handle style declarations?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

So my question is, is this still a generally suggested practice

Only in cargo cult tutorials.

(and is it still really used)

Yes, but not to any useful effect. They are something that were useful in their day, and now (a decade and a half later) just won't die.

In HTML they are useless. In XHTML they are actively harmful (since script elements don't contain implicit CDATA in XHTML so if the document is parsed as XHTML then they will act as an actual comment and hide the script from the browser).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...