Aria-Expanded在没有Aria-Controls的情况下的使用情况是什么?

huangapple go评论99阅读模式
英文:

What are the use-cases for Aria-Expanded without Aria-Controls

问题

我好奇是否有使用aria-expanded属性而不使用aria-controls的用例。

是否有办法“自我声明”一个节点的状态已更改,比如说,一个按钮,可以使用这个属性吗?如果可以:

  • 这只适用于指示按钮是否可见吗?
  • "expanded" 只能表示节点的状态更改吗?

我对aria-expanded的所有用途也有点模糊,因为文档似乎不太完善。它只是用于声明自身的可见性和/或控件吗?它是否可以表示状态更改而不是可见性更改?

关于这个属性的任何教育都将不胜感激。

我已经阅读了很多关于aria-expanded属性的文章和博客文章,仍然不确定是否可以在没有控件的情况下使用该属性,以及在哪些情况下使用它是有效的。

英文:

Im curious if there are use cases for using the aria-expanded attribute without the use of aria-controls.

Are there ways to 'self-declare' per say that the state of a node (lets say, a button) has changed using this attribute? If so:

  • Does this only work for indicating that the button is visible or not?
  • Can 'expanded' represent just a state change for the node?

I'm also a little bit hazy on all the uses for aria-expanded as the documentation seems to not be very solid. Is it just for declaring visibility of self and or controls? Can it indicate a state change rather than visibility change?

Any educating on this attribute would be greatly appreciated.

I have read a whole bunch of articles and blogposts on the aria-expanded attribute and still am not sure if use of the attribute without controls is valid or not, and what the contexts for such use being valid are.

答案1

得分: 1

aria-expanded属性应该设置在一个控制元素上,用于控制一个被控制元素的可见性(该元素的ID是aria-controls的值;例如:"此按钮控制此div")。它允许辅助技术指示其用户,通过操作按钮可以获得一些内容。

参见这个手风琴示例。这是我使用Voice Over的情况:

Aria-Expanded在没有Aria-Controls的情况下的使用情况是什么?

所以,回答你的问题,我认为没有必要。如果没有其他内容可显示,你没有理由说某个东西已经展开了。如果你想要指示一个切换是打开还是关闭,那么aria-pressed似乎是一个更合适的选项。

英文:

The aria-expanded attribute is meant to be set on a operating element that controls the visibility of a controlled element (which id is the value of aria-controls; e.g. "this button controls this div"). It allows assistive technologies to indicate their users that some content is available as a result of operating the button.

See this example of an accordion. And this is me using Voice Over:

Aria-Expanded在没有Aria-Controls的情况下的使用情况是什么?

So to answer your question I don't think there is any. You have no reason to say that something is expanded if there's nothing else to show. If what you wanted was to indicate that a toggle is on or off, then aria-pressed seems a more appropriate option.

huangapple
  • 本文由 发表于 2023年3月10日 00:40:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75687561.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定