另一个你可能想知道的问题是,“为什么不去掉href属性?”我听到的一个常见的回答是href属性是必需的,所以它“应该”;以锚的形式出现。这是假的!href属性只在锚实际上是超链接时才需要!读this from w3。所以,为什么不把它留给占位符呢?浏览器会为元素呈现默认样式,并会更改没有href属性的锚标记的默认样式。相反,它将被视为普通文本。它甚至改变了浏览器关于元素的行为。当鼠标悬停在没有href属性的锚上时,状态栏(屏幕底部)将不会显示。最好在锚上使用占位符href值,以确保它被视为超链接。
1. Absolute path: move to another site like href="http://www.google.com"
2. Relative path: move to another page within the site like herf ="defaultpage.aspx"
3. Move to an element with a specified id within the page like href="#bottom"
4. href="javascript:void(0)", it does not move anywhere.
5. href="#" , it does not move anywhere but scroll on the top of the current page.
6. href= "" , it will load the current page but some browsers causes forbidden errors.
Note: When we do not need to specified any url inside a anchor tag then use
<a href="javascript:void(0)">Test1</a>