我是HTML的新手,我写了一些代码:
<div id = "here">
<a href="#end">
<p>stay here</p>
</div>
<button id="test" onclick="clickSpecialButton('click')">click</button>
<span onmouseover="clickSpecialButton('hover')">hover</span>
<div id="start"></div>
<h1>My first web page</h1>
<figure>
<img src="globe_kyw.jpg" width=90 height=90>
<figcaption>Tixall Obelisk</figcaption>
</figure>
<nav id="main_nav">
<ul>
<li><a href="/tutorials/">Tutorials</a></li>
<li><a href="/reference/">Reference</a></li>
<li><a href="/articles/">Articles</a></li>
<li><a href="/about/">About us</a></li>
</ul>
</nav>
<div id="end">
text
</div>
结果是其中的文字:(“留在这里”,“悬停”,“我的第一个网页”,“Tixall Obelisk”)所有下划线并链接到#end
。
我只想将id = "here"
与div中的内容链接到#end
。
我做了什么错了?
答案 0 :(得分:2)
您忘记关闭a
代码,请尝试在p
代码后关闭代码:
<div id = "here">
<a href="#end">
<p>stay here</p>
</a> <!-- Notice the close tag here -->
</div>
<button id="test" onclick="clickSpecialButton('click')">click</button>
<span onmouseover="clickSpecialButton('hover')">hover</span>
<div id="start"></div>
<h1>My first web page</h1>
<figure>
<img src="globe_kyw.jpg" width=90 height=90>
<figcaption>Tixall Obelisk</figcaption>
</figure>
<nav id="main_nav">
<ul>
<li><a href="/tutorials/">Tutorials</a></li>
<li><a href="/reference/">Reference</a></li>
<li><a href="/articles/">Articles</a></li>
<li><a href="/about/">About us</a></li>
</ul>
</nav>
<div id="end">
text
</div>
&#13;