Closed Bug 217366 Opened 21 years ago Closed 20 years ago

Anchors to div (block) IDs go to the first links inside of that div (block element) instead of the ID location

Categories

(Core :: DOM: Selection, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 258514

People

(Reporter: kevogod, Assigned: mjudge)

References

()

Details

(Keywords: testcase)

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030826
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030826

An anchor to a div ID will focus to the wrong part of the page (namely the first
seen link inside the div) when clicked.  If you manually paste the link into
your browser, it will go to the correct area on the page (ID). 

On Test Site: Click Skip link, it will take you to the Return to Top of Page
anchor instead of just above NEWS where the ID on the div is located.

Reproducible: Always

Steps to Reproduce:
1. Click anchor to ID

Actual Results:  
Puts a selection box around the first link inside of the div with the ID instead

Expected Results:  
Gone to the top of the div with that ID

<a href="#content">content</a> 
<div id="content"> 
   <a href="foo.html">foo.html</a> 
</div>

When the #content anchor is clicked it will put a selection box around the
foo.html anchor link. To get a better test of this case, add line breaks
inbetween the content id and the link to foo.html. Resize Mozilla so that the
page overflows vertically.
Reporter: IIRC, this shouldn't work. Anchors are made like this:

<a href="#content">Go to 'content'</a>.
<a name="content">This is where it will go.</a>.
Vidar: You aren't right, see HTML 4.1 specification:
http://www.w3.org/TR/html4/struct/global.html#adef-id

The id attribute has several roles in HTML:

    * As a style sheet selector.
    * As a target anchor for hypertext links.
    * As a means to reference a particular element from a script.
    * As the name of a declared OBJECT element.
    * For general purpose processing by user agents (e.g. for identifying 
      fields when extracting data from HTML pages into a database, translating 
      HTML documents into other formats, etc.).
Keywords: testcase
Attached file testcase
Also see here: http://www.w3.org/TR/html4/struct/links.html#h-12.2.3

"The id attribute may be used to create an anchor at the start tag of ANY 
element (including the A element)."
It appears that this true for all block elements.
OS: Windows XP → All
Hardware: PC → All
Summary: Anchors to div IDs go to the first links inside of that div instead of the ID location → Anchors to div (block) IDs go to the first links inside of that div (block element) instead of the ID location
Then I did not remember correctly :) Confirmed.
Shouldn't this be somewhere in 'Layout' ?
Status: UNCONFIRMED → NEW
Ever confirmed: true
The problem here is the code that tries to move the caret focus to the "anchor".
  In this case, it ends up putting the focus on the first "focusable" thing past
the point we linked to, which is way lower in this case.

So this is an ESM issue, really....
(In reply to comment #8)
> The problem here is the code that tries to move the caret focus to the 
"anchor".
>   In this case, it ends up putting the focus on the first "focusable" thing 
past
> the point we linked to, which is way lower in this case.
> 
> So this is an ESM issue, really....
After almost 9 months of inactivity, there is life. :P

*** Bug 270349 has been marked as a duplicate of this bug. ***
Per comments in bug 270349, this problem has been fixed in the trunk.  Duping to
the bug that AFAICT covers it

*** This bug has been marked as a duplicate of 258514 ***
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
I've changed the URL. This bug has NOT BEEN RESOLVED.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Comments from the web page: "This issue has not been resolved. I'm using Mozilla
Firefox 1.0 release version. The "Test link to #main" should go directly to the
main id but moves to the nearest link. Also on a side note, why do the links not
change to the visited color when I click on them?"

Firefox 1.0 wouldn't have the fix; it was just checked in on the 12th.  I have
verified that this is fixed in the latest Mozilla 1.8a5 nightly (2004112105)

As for the links changing color, there are bugs filed about visited link issues.

Reclosing.

*** This bug has been marked as a duplicate of 258514 ***
Status: REOPENED → RESOLVED
Closed: 20 years ago20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: