WordPress.org

Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#1765 closed defect (bug) (fixed)

Simplify and standardize anchor syntax

Reported by: h3h Owned by: markjaquith
Milestone: Priority: normal
Severity: minor Version: 1.6
Component: General Keywords: bg|has-patch bg|commit
Focuses: Cc:

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)

preview-link-fix.diff (1.7 KB) - added by markjaquith 15 years ago.
puts the anchors on the <h2>s

Download all attachments as: .zip

Change History (6)

#1 @markjaquith
15 years ago

  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

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!

#2 @h3h
15 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.

@markjaquith
15 years ago

puts the anchors on the <h2>s

#3 @markjaquith
15 years ago

  • Keywords bg|has-patch bg|commit added

#4 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [2973]) Put the preview anchors on the h2. Props: markjaquith fixes #1765

#5 @(none)
14 years ago

  • Milestone 2.0 deleted

Milestone 2.0 deleted

Note: See TracTickets for help on using tickets.