什么是使用href =“###”在锚标签 [英] What is the use of href="###" in anchor tag

查看:102
本文介绍了什么是使用href =“###”在锚标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一些专业的开发人员项目中看到了这些代码行:

 < a href =###> ; 
...
< / a>

它有什么用?

解决方案


它的用途是什么?


这个问题的另一个答案很好。 / p>

关于锚标记的第一件事... ...



就像我提到的引号,她使用 ### 特别是创建一个不会去任何地方的链接,并且要做到这一点, href 属性必须有一个值。请阅读 w3.org



浏览器呈现元素的默认样式,并且会更改不具有 href 元素的默认样式。 code>属性。相反,它会被认为是普通文本。它甚至会改变浏览器对元素的行为。当悬停不带 href 属性的锚时,状态栏(屏幕底部)将不会显示。因此,最好在锚点上使用占位符 href 值,以确保它被视为超链接。



我经常看到< a href =#> < a href =##> ,超链接中的标签 - 指定窗口应该滚动到的html元素标识。



href =#some_id会滚动到当前页面上的元素,例如< div id =some_id >



href =// example.com/#some_id将转到example.com并滚动到该页面上的ID。
href =#不指定id名称,但确实有相应的位置 - 页面顶部。用 href =#点击一个锚点将把滚动位置移动到最上面。



使用< a href =###> 这会创建一个链接,但它不会去任何地方。您可以从##,###和更多标签中使用它来创建像超链接之类的链接,但它们带你走向无处。

我的结论:


那么,它有什么用处呢?


当您需要超链接时,您可以使用它。它只是告诉浏览器将样式更改为锚标签。 :)



查看本演示...


I see these lines of code in some professional developer project:

<a href="###">
    ...
</a>

What is the use of it?

解决方案

What is the use of it?

Another answer in this questions is good.

The first thing about "Anchor Tag"...

Just like quotes I mentioned, she use ### in particular to create a links that don't go anywhere, and to do that the href attribute must have a value. Please read w3.org mentioned about that.

Browsers render default styles for elements and will change the default style of an anchor tag that doesn't have the href property. Instead, it will be considered like regular text. It even changes the browsers behavior in regards to the element. The status bar (bottom of the screen) will not be displayed when hovering an anchor without the href property. It is most optimal, then, to use a placeholder href value on an anchor to ensure it is treated as a hyperlink.

I've often seen <a href="#">, and <a href="##"> , a hashtag - # within a hyperlink specifies an html element id to which the window should be scrolled.

href="#some_id" would scroll to an element on the current page such as <div id="some_id">.

href="//example.com/#some_id" would go to example.com and scroll to the id on that page. href="#" doesn't specify an id name, but does have a corresponding location - the top of the page. Clicking an anchor with href="#" will move the scroll position to the top.

So, when you use <a href="###"> this create a links but it doesn't go anywhere. You can use it from "##","###" and more of hashtag to create a links like a "Hyperlinks" but they take you nowhere.

My Conclusion :

So, What is the use of it ?

You use it, when you need a Hyperlinks that don't go anywhere. It's just tell the browsers to change the style to an anchor tag. :)

Check this demo...

这篇关于什么是使用href =“###”在锚标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆