HTML 导航标签未按预期工作
HTML Nav tag not working as intended
我正在尝试 html,想制作自己的网站。我试图在页面左侧获取指向我最常用网站的链接,因为我相信这就是 nav 所做的。此外,我似乎无法在页面中央获得文本正文,也无法在页眉中获得文本正文。这是我的代码;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first webpage</title>
</head>
<header>Ian Witkowski</header>
<nav>
<h1>My Favorite Websites</h1>
<ul>
<li><a href=http://www.youtube.com/>YouTube</a>
<li><a href=http://www.google.com/>Google</a>
<li><a href=http://www.reddit.com/>Reddit</a>
</ul>
</nav>
<body>
<article>
<h1>The Penultimate Website</h1>
<h2>The Official Homepage of Ian Witkowski</h2>
<p>Thank you for visiting my webpage!</p>
<dl>
<dt><h3>Ian Witkowski</h3></dt>
<dd>A cool dude</dd>
</dl>
<p>
Reasons Ian is cool;</p>
<ul>
<li>He is nice</li>
<li>He rides bikes</li>
<li>He likes computers</li>
<li>He can code his own website</li>
</ul>
<p>Here is a link for my arbitrary code test page;</p>
<ul>
<li><a href="secondpage.htm" target="_blank">Ian2</a></li>
</ul>
</article>
</body>
</html>
nav
什么都不做。它只是一个像 div
这样的标签。但是在 HTML5 规范的一部分,他们添加了 section, nav, footer, header
标签来简化页面的描述。
没有css,它只是一个标签,没有任何关于设计的特殊行为
其次,您的 html 有误。除了头部之外的所有东西都应该在里面 body (包括导航)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first webpage</title>
</head>
<body>
<header>Ian Witkowski</header>
<nav>
<h1>My Favorite Websites</h1>
<ul>
<li><a href=http://www.youtube.com/>YouTube</a>
<li><a href=http://www.google.com/>Google</a>
<li><a href=http://www.reddit.com/>Reddit</a>
</ul>
</nav>
<article>
<h1>The Penultimate Website</h1>
<h2>The Official Homepage of Ian Witkowski</h2>
<p>Thank you for visiting my webpage!</p>
<dl>
<dt><h3>Ian Witkowski</h3></dt>
<dd>A cool dude</dd>
</dl>
<p>
Reasons Ian is cool;</p>
<ul>
<li>He is nice</li>
<li>He rides bikes</li>
<li>He likes computers</li>
<li>He can code his own website</li>
</ul>
<p>Here is a link for my arbitrary code test page;</p>
<ul>
<li><a href="secondpage.htm" target="_blank">Ian2</a></li>
</ul>
</article>
</body>
</html>
我正在尝试 html,想制作自己的网站。我试图在页面左侧获取指向我最常用网站的链接,因为我相信这就是 nav 所做的。此外,我似乎无法在页面中央获得文本正文,也无法在页眉中获得文本正文。这是我的代码;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first webpage</title>
</head>
<header>Ian Witkowski</header>
<nav>
<h1>My Favorite Websites</h1>
<ul>
<li><a href=http://www.youtube.com/>YouTube</a>
<li><a href=http://www.google.com/>Google</a>
<li><a href=http://www.reddit.com/>Reddit</a>
</ul>
</nav>
<body>
<article>
<h1>The Penultimate Website</h1>
<h2>The Official Homepage of Ian Witkowski</h2>
<p>Thank you for visiting my webpage!</p>
<dl>
<dt><h3>Ian Witkowski</h3></dt>
<dd>A cool dude</dd>
</dl>
<p>
Reasons Ian is cool;</p>
<ul>
<li>He is nice</li>
<li>He rides bikes</li>
<li>He likes computers</li>
<li>He can code his own website</li>
</ul>
<p>Here is a link for my arbitrary code test page;</p>
<ul>
<li><a href="secondpage.htm" target="_blank">Ian2</a></li>
</ul>
</article>
</body>
</html>
nav
什么都不做。它只是一个像 div
这样的标签。但是在 HTML5 规范的一部分,他们添加了 section, nav, footer, header
标签来简化页面的描述。
没有css,它只是一个标签,没有任何关于设计的特殊行为
其次,您的 html 有误。除了头部之外的所有东西都应该在里面 body (包括导航)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My first webpage</title>
</head>
<body>
<header>Ian Witkowski</header>
<nav>
<h1>My Favorite Websites</h1>
<ul>
<li><a href=http://www.youtube.com/>YouTube</a>
<li><a href=http://www.google.com/>Google</a>
<li><a href=http://www.reddit.com/>Reddit</a>
</ul>
</nav>
<article>
<h1>The Penultimate Website</h1>
<h2>The Official Homepage of Ian Witkowski</h2>
<p>Thank you for visiting my webpage!</p>
<dl>
<dt><h3>Ian Witkowski</h3></dt>
<dd>A cool dude</dd>
</dl>
<p>
Reasons Ian is cool;</p>
<ul>
<li>He is nice</li>
<li>He rides bikes</li>
<li>He likes computers</li>
<li>He can code his own website</li>
</ul>
<p>Here is a link for my arbitrary code test page;</p>
<ul>
<li><a href="secondpage.htm" target="_blank">Ian2</a></li>
</ul>
</article>
</body>
</html>