#1765 closed defect (bug) (fixed)
Simplify and standardize anchor syntax
| Reported by: | h3h | Owned by: | markjaquith |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 1.6 |
| Severity: | minor | Keywords: | bg|has-patch bg|commit |
| Cc: | Focuses: |
Description
n a semi-recent changeset [2906], there are anchors that are being
created on the admin post page. I've also seen more recent patches with the same. The HTML uses the following syntax:
<a id="preview-post"></a>
I am wondering why this specific syntax is being used instead of
simply adding the same id to the h2 element itself, like so:
<h2 id="preview-post"><?php _e('Post Preview (updated when post is
saved)'); ?> ...
As far as I know, using the A element for anchoring is a thing of the
past, and even then it was <a name="..."> (an empty element without
the closing </a>).
Clarification on this usage would be appreciated and I think it would
be good to establish a product-wide standard for anchor syntax (if one
doesn't already exist).
Attachments (1)
Change History (6)
#2
@
21 years ago
- Keywords anchor syntax removed
After some research it seems that all version 5+ browsers support linking to elements with an id. However, the HTML 4 Spec states that id should only be used on non-A elements. That is, if you're going to use A elements, use <a name="..." />.
This is only necessary if we're looking to support anchor linking in NN4 or other archaic browsers. This isn't crucial functionality and I think we've broken compatibility in enough other areas that it makes sense to just use the <x id="..."> format, where x is some element like a header.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Honestly, I have no idea how widespread support for id anchors on non-<a /> elements is in older browsers, so I used what I know works. If you can give me some assurance that <h2 id="preview-post"> would work widely, I'll gladly make the patch!