html5快捷键
HTML 5 is somewhat looser in its requirements for markup compared to XHTML, allowing a number of shortcuts:
与XHTML相比,HTML 5对标记的要求稍微宽松一些,允许许多快捷方式:
- Tags can be written uppercase, lowercase, or in mIxEd case. 标签可以大写,小写或混合大小写。
You can drop a lot of closing tags:
</li>
,</dt>
,</dd>
,</tr>
,</th>
,</td>
,</thead>
,</tfoot>
,</tbody>
,</option>
,</optgroup>
,</p>
(in most cases),</head>
,</body>
and</html>
are not required.您可以删除许多结束标记:
</li>
,</dt>
,</dd>
,</tr>
,</th>
,</td>
,</thead>
,</tfoot>
,</tbody>
,</option>
,</optgroup>
,</p>
(在大多数情况下),</head>
,</body>
和</html>
是不需要的。Attribute values only need to be quoted if they contain spaces or some non-alphanumeric characters (such as a question mark). So
<div id=wrapper>
is legitimate, as is<img src=assets/images/falls.jpg …>
but<img alt=Angel Falls …>
is not.如果属性值包含空格或某些非字母数字字符(例如,问号),则只需将其引起引用。 因此,
<div id=wrapper>
是合法的,<img src=assets/images/falls.jpg …>
但<img alt=Angel Falls …>
是不合法的。No
type
attribute is required on scripts or stylesheets: a link to a CSS file can be written as<link rel=stylesheet href=styles.css>
脚本或样式表上不需要
type
属性: CSS文件的链接可以写为<link rel=stylesheet href=styles.css>
You will see these shortcuts used in some code examples on this blog in order to save space. If web development is new to you I strongly suggest that you stick to the basic rules for writing HTML code. (Your web page will continue to work fine, and the code will likely be easier for you to read). Once you’re familiar with HTML, you can start to introduce exceptions. You’ll also find that many text editors and IDEs, such as DreamWeaver will fight any attempts at shortcuts, automatically closing tags or suggesting there are errors on the page unless you change their preference settings.
您将在此博客的一些代码示例中看到这些快捷方式,以节省空间。 如果您对Web开发不熟悉,我强烈建议您遵循编写HTML代码的基本规则 。 (您的网页将继续正常运行,并且代码可能更易于阅读)。 熟悉HTML之后,就可以开始引入例外了。 您还会发现,许多文本编辑器和IDE(例如DreamWeaver)将与任何尝试使用快捷方式,自动关闭标签或暗示页面上有错误的尝试相抵触 ,除非您更改其首选项设置。
html5快捷键