Skip to content

[css-anchor-position]: consistent naming convention for anchor-related properties #12789

@AleksandrHovhannisyan

Description

@AleksandrHovhannisyan

Hello! This is my first time contributing an issue to this repo. I'm not sure if this is the place to ask questions, especially for something one could consider to be a matter of opinion or personal preference.

I was reading up on the CSS anchoring API and was wondering why some properties use the anchor- prefix while others use position-. For example:

.target {
  anchor-name: --my-anchor;
}
.anchored-element {
  position-anchor: --my-anchor;
  position-area: end end;
}

My understanding is that the anchoring API is just a natural extension of CSS positioning, allowing us to position elements relative to each other as opposed to just statically, absolutely, or fixed to the viewport. I assume this is why those names were chosen.

But as an end user, I normally expect related properties to share a common naming convention. This improves the developer experience by reducing mental load and the need to remember two naming schemes. It also makes it easier to find the properties you're looking for in editors that have autocomplete. If I know I want to work with the anchoring API, I'd just type anchor- and expect to see all available properties.

For example, I would argue that code like this reads more naturally and is easier to remember:

.target {
  anchor-name: --my-anchor;
}
.anchored-element {
  anchor-target: --my-anchor;
  anchor-[position|point|whatever]: end end;
}

Since the anchoring API was already released over a year ago in Chrome, I assume a change like this wouldn't be realistic at this point in time (but again, I'm new to this process, so maybe it would?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions