简体   繁体   中英

How to Link To a Border Instead of <p>, <h1>, <h2>, etc

I have a long one-page HTML webpage with anchored links (llorch.org). But I want links to the blue border instead of h2.

<h2><a name="AboutMe">Sobre m&#237;</a></h2>.

In order to make that possible, I tried to link to div instead of h1. So.

<a name="expositio1"><div class="expositio"></a>
<h2><a name="AboutMe">Sobre m&#237;</a></h2>

And it works: http://jsfiddle.net/jv4cK/

But it's not validated.

Is there another way to link to a border? Oh, I forgot to say: it works in every browser, except IE. IE makes this weird border above the blue one.

Where you currently have:

<div class="expositio"><a name="expositio2"></a>

Adjust it to use:

<div class="expositio" id="expositio2">

The existing bookmark for #expositio2 should jump to an element with this id. Using the name attribute is actually deprecated, so using an id is the correct way to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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