HTML代码缩进问题

时间:2017-06-01 22:23:47

标签: html indentation

我一直在做一个关于html的codecadmey课程,其中一项任务是编写代码,使其遵循万维网联盟的规则,通过2个空格缩进。我问了几个人在哪里放置缩进但每次都我尝试我仍然无法继续下一个任务。在这里,我的代码可以帮助我填写缩进。



<!DOCTYPE html>
<html>
<head>
  <title>Animals Around the World</title>
</head>
<body>
  <h1> The Brown Bear </h1>
  <p> The brown bear (Ursus arctos) is native to parts of northern Eurasia and North America. Its conservation status is currently "Least Concern." There are many subspecies within the brown bear species, including the Atlas bear and the Himalayan brown bear.  </p>
  <a href="https://en.wikipedia.org/wiki/Brown_bear"    target="_blank"> Learn more </a>
  <p> The following are subspecies of bears: </p>
  
  <ul>               
    <li> Arctos </li>
    <li> Collarus </li>
    <li> Horribilis </li>
    <li> Nelsoni (extinct) </li>
  </ul>
	<p> The following countries have the largest populations of brown bears:  </p>
  <ol>      
    <li> Russia </li>
    <li> United States </li>
    <li> Canada </li>
  </ol>
  <a href="https://en.wikipedia.org/wiki/Brown_bear"target="_blank">
    <img src="https://s3.amazonaws.com/codecademy-content/courses/web-101/web101-image_brownbear.jpg" alt="bear photo"/></a>
 </body> 
</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

检查你的间距。例如,在下面的链接上,你应该在href和目标之间留一个空格。

  <a href="https://en.wikipedia.org/wiki/Brown_bear"target="_blank">

应该是

  <a href="https://en.wikipedia.org/wiki/Brown_bear" target="_blank">

答案 1 :(得分:0)

&#13;
&#13;
<!DOCTYPE html>
<html>

<head>
  <title>Animals Around the World</title>
</head>

<body>
  <h1> The Brown Bear </h1>
  <p> The brown bear (Ursus arctos) is native to parts of northern Eurasia and North America. Its conservation status is currently "Least Concern." There are many subspecies within the brown bear species, including the Atlas bear and the Himalayan brown bear.
  </p>
  <a href="https://en.wikipedia.org/wiki/Brown_bear" target="_blank"> Learn more </a>
  <p> The following are subspecies of bears: </p>

  <ul>
    <li> Arctos </li>
    <li> Collarus </li>
    <li> Horribilis </li>
    <li> Nelsoni (extinct) </li>
  </ul>
  <p> The following countries have the largest populations of brown bears: </p>
  <ol>
    <li> Russia </li>
    <li> United States </li>
    <li> Canada </li>
  </ol>
  <a href="https://en.wikipedia.org/wiki/Brown_bear" target="_blank">
    <img src="https://s3.amazonaws.com/codecademy-content/courses/web-101/web101-image_brownbear.jpg" alt="bear photo" /></a>
</body>

</html>
&#13;
&#13;
&#13;

最快的解决方案是使用您在网上找到的HTML Tidy工具,以便下载并安装它。但是,也有一些网站可以立即使用该工具,例如 codepen.io 。但是,实际上这比你需要花费更多的努力,因为StackOverflow上存在一个整洁的工具,作为OP用来显示相关HTML代码的功能的一部分。如果OP要单击选项以编辑提出的问题,则会提供一个链接(&#34;编辑上面的代码段&#34;),以便编辑代码。如果单击该链接,您将在左侧注明一个适用于HTML,CSS或JavaScript的整洁工具。因此,您可以选择有效地利用此工具来获得所需的缩进代码,或者直观地扫描代码的每一行和字符,以便自己找出间距需要调整的位置。