可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am just curious really and hope that someone can reveal the method in the madness of the W3C. What is the reason for not supporting this tag in the latest HTML5 standard? I know the tag was deprecated in HTML 4.01, but I don't understand why.
It seemed perfectly logical to me, you have a a paragraph of text and just wish to change the font, or to identify, lines or words from it using the font tag, now the only way to do the job is with the span tag. It seems strange to me that there are so many ways to create a block of text, using div, section, or just paragraph, but to wrap a few keywords or any inline content, there is only the span tag.
And really, one little tag can't do any harm, so why not still support it?
Thank you,
Luke
回答1:
In short:
HTML is a markup language. Use it to mark up the different sections of your content using the most semantically accurate element.
CSS is used for styling purposes, such as changing colors, sizes, fonts, etc.
The <font> tag was used for styling, not marking up a section of your content. That's why it's deprecated, along with other out-of-place tags such as <center>.
回答2:
HTML tags describe their contents. To mark up your HTML you should use CSS. In such way you can create different skins for the same information. Since the font tag serves purely visual purpose, it has no place in HTML; it does not describe the contents.
With describing contents I mean: "This is paragraph of text / this is a time / this is a link to another page / this is the title of this article / this is a list of related terms / this is a table containing test results" etc.
Read up on semantic HTML, it will hopefully make things more clear for you.
回答3:
There are lots of ways to wrap inline content, but only one of them has no semantics associated with it (span). Of the list of block wrappers you gave, only div has no semantics associated with it.
The old font element has no semantics associated with it, so it contributes as much as span and can be replaced by span.
The idea is that you pick the element that describes why the text looks different (<em>, <cite>, <dfn>, etc) and then apply CSS to make it look the way you want.
And really, one little tag can't do any harm, so why not still support it?
It is supported, the rendering rules describe how browsers should handle the font element. This is for backwards compatibility. Authors are just forbidden from using it (since it does no good).
回答4:
Truthfully: because w3c are nuts (who are these people who create these standards anyway?) The reality is for all the PR about having to comply from W3C, the practical reality is that browsers ignore these standards.
Fortunately what matters is whether browsers accept it - and as most browsers largely ignore the doctype only choosing between three modes (quirks, semi-quirks and non-quirks) what matters is what mode the browser selects.
As far as I can tell you can present a browser an html 1.0 or html 5.0 and so long as it triggers the same mode, the browser will treat the HTML in exactly the same way. The only difference is if you ask W3C to validate it - which tells you all you need to know about the need for W3C validation!