Skip to content

add a element to mathml-core #142#307

Merged
bkardell merged 2 commits into
mainfrom
a-element
Jan 20, 2026
Merged

add a element to mathml-core #142#307
bkardell merged 2 commits into
mainfrom
a-element

Conversation

@davidcarlisle

Copy link
Copy Markdown
Collaborator

This adds a new section describing an <a> element to address #142

It has the layout rules of mrow and the attributes and behavior of HTML <a>

The exact words in particular the wording to pull in all the behaviors and accessibility/security issues of links probably needs further adjustment but if this PR could be merged sooner rather than later it would put down the intention to add linking to mathml-core and allow the mathml4 draft to have target sections to reference and polyfills and examples updated etc.

In the spec I have stated that all attributes of html <a> are allowed but only highlighted href so attributes such as target or rel are allowed but not described here. We could describe (or at least list) them explicitly here if that was thought necessary although for example we don't explicitly list all the event handler attributes such as onclick we just reference the html spec.

@davidcarlisle davidcarlisle self-assigned this Jan 7, 2026
@bkardell

bkardell commented Jan 8, 2026

Copy link
Copy Markdown
Collaborator

lgtm - I'm asking some people about the best way to go past this- but I don't think it blocks this first

@davidcarlisle

Copy link
Copy Markdown
Collaborator Author

Assuming we do allow the additional link related attributes such as target= here then we should probably do the same for mathML full, which in the latest draft makes <a> an alias for mrow so only allows href.

I suspect we should probably allow them all on mrow to maintain that a is the same as mrow in mathml4- full.

Also once a native mathml a is implemented,the existing href polyfill could polyfill the global href attribute by wrapping the element in an <a. and then moving all the link related attributes, rather than using a javascript implemented link behavior, which as @bkardell has commented misses some features.

Comment thread spec.html Outdated
Comment thread spec.html
Comment thread spec.html
<p>
The <code>&lt;a&gt;</code> element accepts the attributes described
in <a href="#global-attributes"></a> as well as the all the attributes of the
<a href="https://html.spec.whatwg.org/#the-a-element">corresponding element in HTML</a>.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know yet if we want to support all the attributes or just href. I wonder what SVG is doing?

Maybe we should check existing implementations and ask browser vendors for feedback here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SVG lists the attributes explicltly but is I think all of them https://svgwg.org/svg2-draft/linking.html#AElement, so ping, download etc not just href

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice SVG support isn't quite what is specified just as an fyi.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relevant discussion whatwg/html#12063

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think regardless of that some IDL would be useful. For example, HTML A and Area elements when you call .toString() returns the href value. SVG does not have this, so it would be good to define if that behaviour is wanted.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think no... I want to hear some reasoning but it seems weirdly esoteric... It would be not great if relevant parts of math turned into URLs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main requirement here is for linking in MathML. Using <a> and adopting the properties of HTML a are more about trying to better integrate MathML into the web platform, so whatever makes the most sense from an implementation perspective would I think be fine. Agreed it needs to be specified but I think changes from HTML a are fine if they don't cause implementation issues

@davidcarlisle

Copy link
Copy Markdown
Collaborator Author

Would it be possible to merge this as-is now to document <a> as an element in MathML core and to fix the issue with linking to a from mathml4?

The exact details of which attributes get copied over from HTML <a> and the IDL etc could be addressed in followup issues.

@davidcarlisle davidcarlisle changed the title add a element to mathml-code #142 add a element to mathml-core #142 Jan 17, 2026
@bkardell

Copy link
Copy Markdown
Collaborator

@davidcarlisle I think it's fine to merge for now - we can improve it as upstream changes. Maybe we immediately could open a followon

@bkardell bkardell merged commit 98d7316 into main Jan 20, 2026
3 checks passed
github-actions Bot added a commit that referenced this pull request Jan 20, 2026
SHA: 98d7316
Reason: push, by bkardell

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants