Open josepharhar opened 1 year ago
I'm a bit confused about this... I guess the idea would be that anchor
would be looked up after trying an anchor name if it's not found... But have we considered adding a way of using an element id in anchor-default
? Then it can be a regular mapped attribute, instead of a new magic thing?
I'm a bit confused about this... I guess the idea would be that anchor would be looked up after trying an anchor name if it's not found... But have we considered adding a way of using an element id in anchor-default? Then it can be a regular mapped attribute, instead of a new magic thing?
As far as I know, there aren't any other CSS properties which refer to elements by ID, except mask and clip-path which can refer to them with the url syntax which we wouldn't want for this. Would this be easy to do in a way which allows you to refer to either element IDs or anchor-name values?
Using an HTML attribute also has the benefits of assigning to element.anchorElement imperatively without an ID and that setting up relationships between elements seems like something that HTML attributes are already well suited for.
I commented on the spec PR. This still feels a bit of a smell to me but I understand it enables useful things. I think at least we should have a name for this that reflects what it really is (an implicit / fallback thing compared to CSS's anchor-name), to avoid author confusion... But I wonder if @jwatt has different opinions here.
Just saw this comment, sorry. To avoid having the conversation two places, let’s chat on the spec PR.
Request for Mozilla Position on an Emerging Web Specification
Other information
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-elementBy using the
anchor
attribute, you don't have to use theanchor-name
andanchor-default
CSS properties to set up an anchor positioning relationship.Here is an example without the anchor attribute:
And here is an example of the same thing with the anchor attribute which gets rid of
anchor-name
andanchor-default
: