繁体   English   中英

HTML代码缩进问题

[英]HTML code indentation issues

我一直在用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> 

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

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

应该

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

 <!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> 

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM