结构化一个页面的内容 - MDN html 作业

前言

本文将会解析来自MDN web docs的一份html作业,内容较为基础,有一定html知识的同学可以选择绕道。

作业描述

作业地址:结构化一个页面的内容

将上述页面提供的html文件加上结构化标签,使应用于结构化标签的css生效。

答案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Birdwatching</title>
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300|Cinzel+Decorative:700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="styles/index.css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>

<body>

<header>
<h1>Birdwatching</h1>

<img src="images/dove.png" alt="a simple dove logo">

<nav>
<ul>
<li><span>Home</span></li>
<li><a href="#">Get started</a></li>
<li><a href="#">Photos</a></li>
<li><a href="#">Gear</a></li>
<li><a href="#">Forum</a></li>
</ul>
</nav>
</header>

<main>
<article>
<h2>Welcome</h2>

<p>Welcome to our fake birdwatching site. If this were a real site, it would be the ideal place to come to learn more
about birdwatching, whether you are a beginner looking to learn how to get into birding, or an expert wanting to
share ideas, tips, and photos with other like-minded people.</p>

<p>So don't waste time! Get what you need, then turn off that computer and get out into the great outdoors!</p>
</article>

<aside>
<h2>Favourite photos</h2>

<a href="images/favorite-1.jpg"><img src="images/favorite-1_th.jpg"
alt="Small black bird, black claws, long black slender beak, links to larger version of the image"></a>
<a href="images/favorite-2.jpg"><img src="images/favorite-2_th.jpg"
alt="Top half of a pretty bird with bright blue plumage on neck, light colored beak, blue headdress, links to larger version of the image"></a>
<a href="images/favorite-3.jpg"><img src="images/favorite-3_th.jpg"
alt="Top half of a large bird with white plumage, very long curved narrow light colored break, links to larger version of the image"></a>
<a href="images/favorite-4.jpg"><img src="images/favorite-4_th.jpg"
alt="Large bird, mostly white plumage with black plumage on back and rear, long straight white beak, links to larger version of the image"></a>
</aside>
</main>

<footer>
<p>This fake website example is CC0 — any part of this code may be reused in any way you wish. Original example written
by Chris Mills, 2016.</p>

<p><a href="http://game-icons.net/lorc/originals/dove.html">Dove icon</a> by Lorc.</p>
</footer>

</body>
</html>

使用到的结构化标签有:

  1. header:页眉
  2. nav:导航栏
  3. main:主要内容
  4. article:文章
  5. aside:侧边栏
  6. footer:页脚

这里需要注意,仅仅设置这些html标签是不会对页面的布局产生任何影响的,这些标签只是作为页面结构的标识,以便后续使用css等手段对页面进行排版调整所用。