首页前端开发HTMLHTML5的结构和语义――语义性的块级元素(三)

HTML5的结构和语义――语义性的块级元素(三)

时间2024-01-25 14:14:18发布访客分类HTML浏览791
导读:收集整理的这篇文章主要介绍了html5教程-HTML5的结构和语义――语义性的块级元素(三),觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。 asi...
收集整理的这篇文章主要介绍了html5教程-HTML5的结构和语义――语义性的块级元素(三),觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。 aside  figure   diaLOG
 
  我在文章和书中一直使用前两个元素。第三个元素我不经常用,它主要用于书面文本。
 
aside
 
  aside 元素代表说明、提示、边栏、引用、附加注释等,也就是叙述主线之外的内容。例如,在develoPErWorks 文章中,经常会看到用表格形式编写的边栏,见代码3 用HTML 4 编写的developerWorks 边栏。
 
以下是代码片段:[www.2cto.COM ]
table align="right" border="0" cellpadding="0" cellspacing="0" width="40%">
tbody> tr> td width="10">
img alt="" src="//www.ibm.com/i/c.gif" height="1" width="10"> /td>
td>
table border="1" cellpadding="5" cellspacing="0" width="100%">
tbody> tr> td bgcolor="#eeeeee">
p> a name="xf-value"> span class="smalltITle"> .xf-value/span> /a> /p>
p>
The code type="inline"> .xf-value/code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
code type="inline"> ::value/code> pseudo-class instead like so:
/p>
table border="0" cellpadding="0" cellspacing="0" width="100%">
tbody> tr> td class="code-outline">
PRe class="displaycode"> input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em } /pre>
/td> /tr> /tbody> /table> br>
 
p>
However, Firefox doesn't yet support this syntax.
/p>
/td> /tr> /table>
 
  在html 5 中,可以按照更有意义的方式编写这个边栏,见代码4 用HTML 5 编写的developerWorks 边栏。
 
以下是代码片段:[www.2cto.com ]
aside>
h3> .xf-value/h3>
p>
The code type="inline"> .xf-value/code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
code type="inline"> ::value/code> pseudo-class instead like so:
/p>
 
pre class="displaycode"> input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em } /pre>
 
p>
However, Firefox doesn't yet support this syntax.
/p>
/aside>
 
  浏览器可以决定把这个边栏放在哪里(可能需要用一点儿CSS 代码)。
 
figure
 
  figure 元素代表一个块级图像,还可以包含说明。例如,在许多developerWorks 文章中,可以看到代码5 用HTML 4 编写的developerWorks 图 这样的标记其结果见图1。
 
以下是代码片段:[www.2cto.com ]
a name="fig2"> b> Figure 2. Install Mozilla XForms dialog/b> /a> br />
img alt="A Web site is requesting permission to install the following item:
Mozilla XForms 0.7 Unsigned"
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
br />





图 1. Install Mozilla XForms dialog 


  在 HTML 5 中,可以按照更有语义性的方式编写这个图,见代码6 用 HTML 5 编写的 developerWorks 图。

 
以下是代码片段:[www.2cto.com ]
figure id="fig2">
legend> Figure 2. Install Mozilla XForms dialog/legend>
img alt="A Web site is requesting permission to install the following item: 
Mozilla XForms 0.7 Unsigned" 
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
/figure>
 
 
  最重要的是,浏览器(尤其是屏幕阅读器)可以明确地将图和说明联系在一起。
  figure 元素不只可以显示图片。还可以使用它给audio、video、iframe、object 和embed 元素加说明。
 
dialog
 
  dialog 元素表示几个人之间的对话。HTML 5 dt 元素可以表示讲话者,HTML 5 dd 元素可以表示讲话内容。所以,在老式浏览器中也可以以合理的方式显示对话。代码7 显示在Galileo 的 “Dialogue Concerning the Two Chief World Systems” 上的一段闻名对话。
 
  代码7. 用HTML 5 编写的Galilean 对话
 
 
 
以下是代码片段:[www.2cto.com ]
dialog>
dt> Simplicius /dt>
dd> According to the straight line AF,
and not according to the curve, such being already excluded
for such a use./dd>
 
dt> Sagredo /dt>
dd> But I should take neither of them,
seeing that the straight line AF runs obliquely. I should
draw a line perpendicular to CD, for this would seem to me
to be the shor@R_512_2187@, as well as being unique among the
infinite number of longer and unequal ones which may be
drawn From the point A to every other point of the opposite
line CD. /dd>
 
dt> Salviati /dt>
dd> p> Your choice and the reason you
adduce for it seem to me most excellent. So now we have it
that the First dimension is determined by a straight line;
the second (namely, breadth) by another straight line, and
not only straight, but at right angles to that which
determines the length. Thus we have defined the two
dimensions of a Surface; that is, length and breadth. /p>
 
p> But suppose you had to determine a height—for
example, how high this platform is from the pavement down
below there. Seeing that from any point in the platform we
may draw infinite lines, curved or straight, and all of
different lengths, to the infinite points of the pavement
below, which of all these lines would you make use of? /p>
/dd>
/dialog>
 
 
  对于这个元素的准确语法还有争议。一些人希望在dialog 元素中嵌入非对话文本(比如剧本中的舞台说明),还有人不喜欢扩展dt 和dd 元素的作用。尽管在具体语法方面有争议,但是大多数人都认为以这样的语义性方式表达对话是好事情

aside  figure   dialog
 
  我在文章和书中一直使用前两个元素。第三个元素我不经常用,它主要用于书面文本。
 
aside
 
  aside 元素代表说明、提示、边栏、引用、附加注释等,也就是叙述主线之外的内容。例如,在developerWorks 文章中,经常会看到用表格形式编写的边栏,见代码3 用HTML 4 编写的developerWorks 边栏。
 
以下是代码片段:[www.2cto.com ]
table align="right" border="0" cellpadding="0" cellspacing="0" width="40%">
tbody> tr> td width="10">
img alt="" src="//www.ibm.com/i/c.gif" height="1" width="10"> /td>
td>
table border="1" cellpadding="5" cellspacing="0" width="100%">
tbody> tr> td bgcolor="#eeeeee">
p> a name="xf-value"> span class="smalltitle"> .xf-value/span> /a> /p>
p>
The code type="inline"> .xf-value/code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
code type="inline"> ::value/code> pseudo-class instead like so:
/p>
table border="0" cellpadding="0" cellspacing="0" width="100%">
tbody> tr> td class="code-outline">
pre class="displaycode"> input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em } /pre>
/td> /tr> /tbody> /table> br>
 
p>
However, Firefox doesn't yet support this syntax.
/p>
/td> /tr> /table>
 
  在HTML 5 中,可以按照更有意义的方式编写这个边栏,见代码4 用HTML 5 编写的developerWorks 边栏。
 
以下是代码片段:[www.2cto.com ]
aside>
h3> .xf-value/h3>
p>
The code type="inline"> .xf-value/code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
code type="inline"> ::value/code> pseudo-class instead like so:
/p>
 
pre class="displaycode"> input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em } /pre>
 
p>
However, Firefox doesn't yet support this syntax.
/p>
/aside>
 
  浏览器可以决定把这个边栏放在哪里(可能需要用一点儿CSS 代码)。
 
figure
 
  figure 元素代表一个块级图像,还可以包含说明。例如,在许多developerWorks 文章中,可以看到代码5 用HTML 4 编写的developerWorks 图 这样的标记其结果见图1。
 
以下是代码片段:[www.2cto.com ]
a name="fig2"> b> Figure 2. Install Mozilla XForms dialog/b> /a> br />
img alt="A Web site is requesting permission to install the following item:
Mozilla XForms 0.7 Unsigned"
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
br />





图 1. Install Mozilla XForms dialog 


  在 HTML 5 中,可以按照更有语义性的方式编写这个图,见代码6 用 HTML 5 编写的 developerWorks 图。

 
以下是代码片段:[www.2cto.com ]
figure id="fig2">
legend> Figure 2. Install Mozilla XForms dialog/legend>
img alt="A Web site is requesting permission to install the following item: 
Mozilla XForms 0.7 Unsigned" 
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
/figure>
 
 
  最重要的是,浏览器(尤其是屏幕阅读器)可以明确地将图和说明联系在一起。
  figure 元素不只可以显示图片。还可以使用它给audio、video、iframe、object 和embed 元素加说明。
 
dialog
 
  dialog 元素表示几个人之间的对话。HTML 5 dt 元素可以表示讲话者,HTML 5 dd 元素可以表示讲话内容。所以,在老式浏览器中也可以以合理的方式显示对话。代码7 显示在Galileo 的 “Dialogue Concerning the Two Chief World Systems” 上的一段闻名对话。
 
  代码7. 用HTML 5 编写的Galilean 对话
 
 
 
以下是代码片段:[www.2cto.com ]
dialog>
dt> Simplicius /dt>
dd> According to the straight line AF,
and not according to the curve, such being already excluded
for such a use./dd>
 
dt> Sagredo /dt>
dd> But I should take neither of them,
seeing that the straight line AF runs obliquely. I should
draw a line perpendicular to CD, for this would seem to me
to be the shortest, as well as being unique among the
infinite number of longer and unequal ones which may be
drawn from the point A to every other point of the opposite
line CD. /dd>
 
dt> Salviati /dt>
dd> p> Your choice and the reason you
adduce for it seem to me most excellent. So now we have it
that the first dimension is determined by a straight line;
the second (namely, breadth) by another straight line, and
not only straight, but at right angles to that which
determines the length. Thus we have defined the two
dimensions of a surface; that is, length and breadth. /p>
 
p> But suppose you had to determine a height—for
example, how high this platform is from the pavement down
below there. Seeing that from any point in the platform we
may draw infinite lines, curved or straight, and all of
different lengths, to the infinite points of the pavement
below, which of all these lines would you make use of? /p>
/dd>
/dialog>
 
 
  对于这个元素的准确语法还有争议。一些人希望在dialog 元素中嵌入非对话文本(比如剧本中的舞台说明),还有人不喜欢扩展dt 和dd 元素的作用。尽管在具体语法方面有争议,但是大多数人都认为以这样的语义性方式表达对话是好事情

觉得可用,就经常来吧! 欢迎评论哦! html5教程,巧夺天工,精雕玉琢。小宝典献丑了!

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

ClassCSScss3divHTMLhtml5post-format-galleryStatethis

若转载请注明出处: HTML5的结构和语义――语义性的块级元素(三)
本文地址: https://pptw.com/jishu/586620.html
《Cut The Rope》 HTML 5版背后的开发故事 开发者视角论述HTML5平台的7大特点

游客 回复需填写必要信息