html icon indicating copy to clipboard operation
html copied to clipboard

Incorporate SVG `a` element in the processing model and algorithms of HTML `a` element

Open goldenboy777 opened this issue 3 months ago • 13 comments

What is the issue with the HTML Standard?

As per the resolution in SVGWG issue Specifying processing model and algorithm for ping and referrerPolicy in SVG a element the hyperlink processing model and algorithms defined in HTML specification should also apply to the SVG a element.

We would like to request feedback from HTML experts on the following:

  • Is it appropriate to extend the existing hyperlink processing model to cover SVG a elements, given their functional parity with the HTML a element?
  • If so, can the https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks-2 be updated to explicitly include SVG a element?

This change would help ensure consistent behavior across HTML and SVG documents.

goldenboy777 avatar Nov 21 '25 07:11 goldenboy777

Doing this seems reasonable, but it's probably a bit more involved than that. You need to check for all references to the a element and see if they need adjusting to also account for SVG a.

annevk avatar Nov 21 '25 07:11 annevk

Got it, I created the HTML issue for starting purposes I will compile the list of references in the HTML spec where such update is required as well. Thanks for the suggestion!

goldenboy777 avatar Nov 21 '25 07:11 goldenboy777

My suggestion for the update: Because of common functionality between HTML A element and SVG A element, any references of a tag should be upated to be explicitly written as HTML a and a reference of SVG a should be added accordingly along with it.

Below are the references in https://html.spec.whatwg.org/multipage/links.html which I found needs to be updated as per my above suggestion.

Section wise links:

https://html.spec.whatwg.org/multipage/links.html#introduction-2 - 2 references needs to be updated

https://html.spec.whatwg.org/multipage/links.html#links-created-by-a-and-area-elements - Title needs to be updated along 
with 8 references

https://html.spec.whatwg.org/multipage/links.html#api-for-a-and-area-elements - Title needs to be updated
along with 3 references

https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks - 4 references needs to be updated

https://html.spec.whatwg.org/multipage/links.html#downloading-resources - 2 references needs to be updated

https://html.spec.whatwg.org/multipage/links.html#hyperlink-auditing - 2 references needs to be updated
 - 
https://html.spec.whatwg.org/multipage/links.html#linkTypes - 1 reference along with a table column heading

https://html.spec.whatwg.org/multipage/links.html#rel-alternate -  1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-author - 3 references

https://html.spec.whatwg.org/multipage/links.html#link-type-bookmark - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-external - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-help - 3 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-license -  1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-nofollow - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-noopener - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-opener - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-privacy-policy - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-search - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-tag - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-terms-of-service - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-next - 1 reference

https://html.spec.whatwg.org/multipage/links.html#link-type-prev - 1 reference

https://html.spec.whatwg.org/multipage/links.html#other-link-types - 6 references

goldenboy777 avatar Nov 22 '25 14:11 goldenboy777

Per https://github.com/w3c/mathml-core/issues/142 MathML will likely also get an element with the same functionality as HTML a.

HTML also has area which can be a hyperlink.

I think the right approach is not for HTML to mention SVG a and MathML a, but to create hooks so that SVG and MathML can easily specify that a particular element type supports the same features and has the same processing as HTML hyperlinks.

HTML already has some attributes that are common among multiple HTML elements, for example https://html.spec.whatwg.org/#cors-settings-attributes and the next few subsections.

zcorpan avatar Nov 24 '25 10:11 zcorpan

I suppose we could have an "hyperlink element" concept and make HTML a and area elements use that. If we need a lot of type-specific branching that might get cumbersome though.

annevk avatar Nov 24 '25 12:11 annevk

Given that there are other hyperlinks like MathML which may require the same behaviour I agree with @zcorpan that hooks for SVG and MathML might be better here (plus it can be extensible in the future if required)

@annevk "hyperlink element" concept is a good idea! will this concept include SVG a and MathML a element as well? in which spec should we include this concept?

goldenboy777 avatar Nov 24 '25 15:11 goldenboy777

I think it's appropriate to keep it in HTML.

zcorpan avatar Nov 24 '25 17:11 zcorpan

should I open a draft PR for this and see what changes we will require?

goldenboy777 avatar Nov 25 '25 10:11 goldenboy777

Sure. Thank you!

zcorpan avatar Nov 25 '25 15:11 zcorpan

I am thinking of Hyperlink element definition as below:

An element is a Hyperlink element if it follows the HTML processing model and its specification explicitly declares that it supports the Hyperlink element concept.

a and area are Hyperlink elements

goldenboy777 avatar Nov 26 '25 15:11 goldenboy777

@zcorpan I had a small question I tried making the change in https://github.com/whatwg/html/blob/main/review-drafts/2025-07.wattsi but I am not sure if that's the correct location to add such concept.

Can you point me to the correct repo for raising the PR?

goldenboy777 avatar Nov 26 '25 15:11 goldenboy777

One thing to be aware of is that the href value for an SVG element behaves differently to that of an html a, area and future MathML a. So we shouldn't reference the attribute too much (have a concept that is equivalent to its value and then SVG can set that concept slightly differently)

lukewarlow avatar Nov 27 '25 10:11 lukewarlow

@goldenboy777 this is the correct repo, but the correct file is source

zcorpan avatar Dec 02 '25 08:12 zcorpan