Html 导航列表和标题之间的链接

Html 导航列表和标题之间的链接,html,Html,我无法从一些nav列表链接到一些h2标题 当我单击文档中的导航栏时,我希望它跳转到页面中的正确标题。这是我的密码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Wisconsin Colleges and Universities</title> <script src="modernizr-1.5.js">

我无法从一些
nav
列表链接到一些
h2
标题

当我单击文档中的导航栏时,我希望它跳转到页面中的正确标题。这是我的密码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Wisconsin Colleges and Universities</title>
    <script src="modernizr-1.5.js"></script>
    <link href="hestyles.css" rel="stylesheet" type="text/css" />
    <base href="url" target="collegeWin"/>
  </head>

   <body>

      <header>
         <img src="highered.jpg" alt="Higher Education" />
      </header>

      <section> 

         <h1>Wisconsin Colleges and Universities</h1>

         <nav>
            <ul>
               <li><a href="#private">Private Colleges and Universities</a></li>
               <li><a href="#technical">Technical College System</a></li>
               <li><a>University of Wisconsin System</a></li>
            </ul>
         </nav>

         <h2 id="private">Private Colleges and Universities</h2>
         <ul>
            <li><a href="http://www.alverno.edu">Alverno College</a></li>
            <!-- ... -->
            <li><a href="http://www.wlc.edu">Wisconsin Lutheran College</a></li>
         </ul>

         <h2 id="technical">Technical College System</h2>
         <ul>
            <li><a href="http://www.blackhawk.edu">Blackhawk Technical College</a></li>
            <!-- ... -->
            <li><a href="http://www.witc.edu">Wisconsin Indianhead Technical College</a></li>
         </ul>

         <h2 id="public">University of Wisconsin System</h2>
         <ul>
            <li><a href="http://www.uwgb.edu">UW-Green Bay</a></li>
            <!-- ... -->
            <li><a href="http://www.uww.edu">UW-Whitewater</a></li>
         </ul>

         <footer>
            Higher &#9830; Ed: The Directory of Higher Education Opportunities
         </footer>
      </section>
   </body>
</html>

威斯康星州学院和大学
威斯康星州学院和大学
技术学院制
威斯康星大学系统
更高♦;教育署:高等教育机会目录

如您所见,我已将ID放在
h2
标题上,并尝试使用带前缀的片段ID链接到它们。但由于某些原因,我收到一条错误消息,说明“找不到。请确保路径或Internet地址正确。”

这是因为您有一个标签
base
。移除它,它就会工作。请参见

像这样尝试

 <li><a href="#private" target="_self">Private Colleges and Universities</a></li>
 <li><a href="#technical" target="_self">Technical College System</a></li>
 <li><a href="#public" target="_self">University of Wisconsin System</a></li>
 </ul>

  • 谢谢!它确实有用!但有一个问题。作业要求我为文档头创建一个基本元素,以便在名为collegeWin的新浏览器中默认打开所有链接。我怎样才能在不破坏h2和链接的情况下成功地添加这个基数?Thierry,我明白了。在文档头中的我的基本元素中,我将href=“url”更改为href=“uwlist.htm”,现在可以使用:)@RudySanchez很棒!请不要忘记接受答案。Thierry,抱歉,还有一个:)我通过,,在另一个窗口中打开网站url链接,但我希望我单击的所有链接都可以打开到同一个窗口,因此我单击的每个链接都不会打开成吨的新窗口。。。有什么想法吗?你试过不同的浏览器吗?没有在上面发布html代码,试过这样做吗