文件类型判断_文件类型

文件类型判断

Doctypes are simply a way to tell the browser—or any other parsers—what type of document they’re looking at. In the case of HTML files, they refer to the specific version and flavor of HTML. The doctype should always be the first item at the top of all your HTML files. In the past, the doctype declaration was an ugly and hard-to-remember mess. For XHTML 1.0 Strict:

Doctypes只是告诉浏览器或其他解析器正在查看的文档类型的一种方式。 对于HTML文件,它们指的是HTML的特定版本和风格。 doctype应该始终是所有HTML文件顶部的第一项。 过去,doctype声明是一个丑陋且难以记忆的混乱。 对于XHTML 1.0 Strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

And for HTML4 Transitional:

对于HTML4 Transitional:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "https://www.w3.org/TR/html4/loose.dtd">

Over the years, code editing software began to provide HTML templates with the doctype already included, or else they offered a way to automatically insert one. And naturally, a quick web search will easily bring up the code to insert whatever doctype you require.

多年以来,代码编辑软件开始为HTML模板提供已经包含的doctype,否则他们提供了自动插入模板的方法。 当然,快速的网络搜索将轻松带出代码来插入您需要的任何文档类型。

Although having that long string of text at the top of our documents hasn’t really hurt us (other than forcing our sites’ viewers to download a few extra bytes), HTML5 has done away with that indecipherable eyesore. Now all you need is this:

尽管在文档的顶部放置一长串文本并没有真正伤害我们(除了迫使我们站点的查看器下载一些额外的字节),HTML5消除了那种难以理解的眼神。 现在您需要的是:

<!doctype html>

Simple, and to the point. You’ll notice that the “5” is conspicuously missing from the declaration. Although the current iteration of web markup is known as “HTML5,” it really is just an evolution of previous HTML standards—and future specifications will simply be a development of what we have today. Because browsers have to support all existing content on the Web, there’s no reliance on the doctype to tell them which features should be supported in a given document.

很简单,而且很重要。 您会注意到声明中明显缺少“ 5”。 尽管当前的Web标记迭代被称为“ HTML5”,但它实际上只是先前HTML标准的演进-将来的规范将仅仅是我们现有内容的发展。 由于浏览器必须支持Web上的所有现有内容,因此无需依赖doctype来告诉他们在给定文档中应支持哪些功能。

翻译自: https://www.sitepoint.com/doctypes/

文件类型判断

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值