惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
L
LangChain Blog
博客园_首页
J
Java Code Geeks
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
WordPress大学
WordPress大学
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
C
Check Point Blog
IT之家
IT之家
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
D
Docker
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
I
InfoQ

Christian Heilmann

Moderators wanted for WeAreDevelopers World Congress North America on the 23rd! Coming to San Jose for the WeAreDevelopers World Congress 23rd of September – get tickets half price now! Quick Tip: Translating long documents with Microsoft Edge Immersive Reader Social Media | Christian Heilmann A blueprint for democracy to defend itself against fascism from 1937 – more important now than ever… TIL: Browsers offer a “copy email” in the context menu on mailto: links Remember: The “f” in xenophobia stands for “fun” How do developers define their worth when code is written by AI? Take the “chart explosion” coding challenge and earn your spot at CODE100 in July in Berlin
Accessibility question: is nesting interactive elements bad?
Chris Heilma · 2026-05-27 · via Christian Heilmann

I am currently writing a gallery script for myself and ran into an interesting accessibility question. I have a list of galleries with links to each of them. I also wanted to provide a checkbox to allow users to select several galleries and merge or download them. The HTML I use is the following. An unordered list with labels and checkboxes and links inside the label.

<ul>
    <li><label>
        <input type="checkbox" name="edit" value="Cats">
        <a href="index.php?gallery=Cats">Cats</a>
    </label></li>
</ul>

Given the right CSS and some breathing space this works well with a mouse and keyboard. You can click next to the link to check the checkbox and on the link to navigate to the gallery. It also works using a keyboard. You can tab through the list and check/uncheck using the space bar. The following screencast shows what that looks like.

Screen recording showing the interaction with the nested link inside the label using mouse and keyboard

Now, it feels wrong though. I am mixing two interaction modes here, navigation and selection, one being link based and the other form based. I am wondering if that creates any issues for screenreader users. The other thing I am wondering about is if there is an issue with nesting all in the label as some older assistive technology didn’t like that. I can work around that using `for` and `ids`:

<ul>
    <li>
        <input id="CBDucks" type="checkbox" name="edit" value="Ducks">
        <label for="CBDucks">
            <a href="index.php?gallery=Ducks">Ducks</a>
        </label>
    </li>
</ul>

The question though is if that is still an accessibility issue and if it doesn’t make more sense to show the navigation as links and create a toggle to switch to the selection use case? What do you think?

You can try out the demo page for yourself here.