Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML anchor attribute #216

Open
josepharhar opened this issue Jun 28, 2023 · 3 comments
Open

HTML anchor attribute #216

josepharhar opened this issue Jun 28, 2023 · 3 comments
Assignees
Labels
from: Google Proposed, edited, or co-edited by Google. topic: html Spec relates to HTML (Hypertext Markup Language) venue: WHATWG HTML Workstream

Comments

@josepharhar
Copy link

josepharhar commented Jun 28, 2023

WebKittens

No response

Title of the spec

HTML anchor attribute

URL to the spec

whatwg/html#9144

URL to the spec's repository

https://github.com/whatwg/html

Issue Tracker URL

No response

Explainer URL

No response

TAG Design Review URL

w3ctag/design-reviews#848

Mozilla standards-positions issue URL

mozilla/standards-positions#836

WebKit Bugzilla URL

No response

Radar URL

No response

Description

The anchor attribute allows HTML to hook into CSS Anchor positioning to set an implicit anchor element: https://drafts.csswg.org/css-anchor-position-1/#implicit-anchor-element

By using the anchor attribute, you don't have to use the anchor-name and anchor-default CSS properties to set up an anchor positioning relationship.

Here is an example without the anchor attribute:

<div id=myanchor>anchor</div>
<div id=positioned>anchor positioned</div>
<style>
div {
  position: absolute;
  width: 100px;
  border: 1px solid black;
}
#anchor {
  top: 50px;
  left: 50px;

  /* needed without the HTML anchor attribute */
  anchor-name: --my-anchor;
}
#positioned {
  top: anchor(bottom);
  left: anchor(left);

  /* needed without the HTML anchor attribute */
  anchor-default: --my-anchor;
}
</style>

And here is an example of the same thing with the anchor attribute which gets rid of anchor-name and anchor-default:

<div id=myanchor>anchor</div>
<div id=positioned anchor=myanchor>anchor positioned</div>
<style>
div {
  position: absolute;
  width: 100px;
  border: 1px solid black;
}
#myanchor {
  top: 50px;
  left: 50px;
}
#positioned {
  top: anchor(bottom);
  left: anchor(left);
}
</style>
@lukewarlow lukewarlow added topic: html Spec relates to HTML (Hypertext Markup Language) venue: WHATWG HTML Workstream from: Google Proposed, edited, or co-edited by Google. labels Jun 28, 2023
@lukewarlow
Copy link
Member

#167 here's the position issue on the CSS spec side of this. Just so if one gets a position the other gets one at the same time (or at least is considered)

@nt1m nt1m self-assigned this Sep 21, 2023
@mfreed7
Copy link

mfreed7 commented Apr 9, 2024

Any feedback on this standards position request?

@nt1m nt1m assigned annevk and fantasai and unassigned nt1m Apr 9, 2024
@annevk
Copy link
Contributor

annevk commented May 31, 2024

Looking at this again we're not quite sure what the semantics of the anchor attribute are? It seems to be entirely presentational.

It makes sense to us that popovers would influence the implicit anchor element, but popovers also create accessibility mappings and do a number of other things. This very much seems presentational, which we've shielded HTML from for the past two decades.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from: Google Proposed, edited, or co-edited by Google. topic: html Spec relates to HTML (Hypertext Markup Language) venue: WHATWG HTML Workstream
Projects
Development

No branches or pull requests

6 participants