为什么我的HTML5代码不起作用?

时间:2014-02-20 22:24:31

标签: html css html5

感谢所有帮助的人,已经固定了! :d 只是想知道为什么我的代码不起作用?在导航栏下我的段落不会显示?另外,我如何将导航栏全部放在一行?对不起,如果这真的很蠢,我是新手!

新的更新代码,不会在底部显示段落。

 <!DOCTYPE html>
 <html>

 <head>
 <link rel="stylesheet" type="text/css" href="stylesheet.css">
 <title> Home </title> 
 </head>

 <body>

 <img src="Andora ski trip.JPG" alt="View from flat in Andora" height="400" width="100%">


 <h1> Home </h1>

 <nav>
  <ul>
   <li><a href="Home.html">Home</a></li>
   <li><a href="Curriculum vitae.html">Curriculum vitae</a></li>
   <li><a href="literature review.html">Literature review</a></li>
   <li><a href="Video.html">Video</a></li>
 </ul>
 </nav>

 <p>My name is Jack Hay and this is the first proper website that i have designed. My aim is to show my CV, some coursework that i have done (Literature review), a short self made video and to learn how to use a stylesheet efficiently</p>

 </body>
 </html>

CSS

 h1{
  font-family:"calibri", Times, Serif;
  colour: White;
  font-size:50px ;
  padding:0.1px;
  margin:5
 }

 ul
 {
   list-style-type: none;
 }

 ul li
 {
   display: block;
   width: 25%
   float: left
 }

3 个答案:

答案 0 :(得分:0)

首先用li标签替换h2标签。这不是有效的HTML。

要将导航放在一行中,您可以在css中执行以下操作:

ul
{
 list-style-type: none;
 }

ul li
{
display: inline-block;
}

答案 1 :(得分:-1)

......你顶部的头部和身体标签搞砸了。

<!doctype html>
<html>

<head>
<title> Curriculum vitae </title> 
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>

<body>



<img src="Andora ski trip.JPG" alt="View from flat in Andora" height="400" width="100%">

<h1> Curriculum vitae </h1>



<nav>
<ul>
<li><a href="Home.html">Home</a></li>
<li><a href="Curriculum vitae.html">Curriculum vitae</a></li>
<li><a href="literature review.html">Literature review</a></li>
<li><a href="Video.html">Video</a></li>
</ul>
</nav>

<p>My name is Jack and this is the first proper website that i have designed. My aim is to show my CV, some coursework that i have done (Literature review), a short self made video and to learn how to use a stylesheet efficiently</p>

</body>

</html>

答案 2 :(得分:-1)

根据您在那里发布的代码,该段落应该显示,可能是您的CSS正在将段落移出屏幕和/或将文本设置为背景颜色

您还应将<h1><img>标签移出头部并将其放入体内。 head标签用于提供浏览器信息,而不是用于包含用户的内容。

要显示您在一行中导航,您需要将导航标签更改为li(不是h2),然后在您的CSS中:

ul
{
 list-style-type: none;
}

ul li
{
 display: block;
 width: 25%
 float: left
}