Human or LLM? A Comparative Study on Accessible Code Generation Capability
Web accessibility is essential for inclusive digital experiences, yet the accessibility of LLM-generated code remains underexplored. This paper presents an empirical study comparing the accessibility of web code generated by GPT-4o and Qwen2.5-Coder-32B-Instruct- AWQ against human-written code. Results show that LLMs often produce more accessible code, especially for basic features like color contrast and alternative text, but struggle with complex issues such as ARIA attributes. We also assess advanced prompting strategies (Zero-Shot, Few-Shot, Self-Criticism), finding they offer some gains but are limited. To address these gaps, we introduce FeedA11y, a feedback-driven ReAct-based approach that significantly outperforms other methods in improving accessibility. Our work highlights the promise of LLMs for accessible code generation and emphasizes the need for feedback-based techniques to address persistent challenges. We provide the source code and datasets that were used in our experiments in the companion website [5].
Introduction. Web accessibility involves designing and developing websites to ensure they are usable by individuals with diverse (dis)abilities [71]. With approximately 15% of the global population living with some form of disability [6], ensuring web accessibility is crucial for providing equal access to all users. Beyond being an ethical responsibility, it is also a legal obligation. The Americans with Disabilities Act (ADA), enforced by the U.S. Department of Justice, mandates that public-facing businesses and government entities provide accessible web content [11]. As such, web accessibility is no longer optional but a legal and ethical requirement [44, 59]. Prior studies have investigated various aspects influencing web accessibility, including software frameworks [22, 37], adaptive user interfaces [28, 62] and design considerations [31, 39, 41, 66] for people with impairments. Additionally, the World Wide Web Consortium (W3C) offers the Web Content Accessibility Guidelines (WCAG) [17], which provide recommendations for improving web accessibility. Despite this, generating more accessible web content remains a growing focus, with significant ongoing research and efforts dedicated to advancing web accessibility [52]. The recent rise of Large Language Models (LLMs) has profoundly impacted the software development process. Models such as GPT- 4o [56], DeepSeek-R1 [29], Llama3 [4], Qwen2.5-Coder [38], and Copilot [3] have demonstrated exceptional performance in tasks including code generation [45, 49, 63, 77] and code repair [35, 68, 79]. Tools like GitHub Copilot [3] leverage LLMs to assist developers by suggesting code snippets, completing functions, and even generating entire blocks of code from minimal input. Consequently, LLMs are transforming the creation and maintenance of software [30]. As LLM use is becoming evermore prevalent in software development, assessing the LLM-generated code quality has become crucial. Previous research has examined various quality aspects, including the functionality of LLM-generated code, to ensure it performs as intended [40, 45, 48]. Additionally, studies on code efficiency [27, 60] and security [67] have evaluated the overall performance and safety of the code produced by LLMs. However, despite this extensive research, the accessibility of LLM-generated code, which is vital for ensuring equal access to software, remains largely underexplored. This is particularly crucial in web development, given the growing use of the internet across diverse devices [36], with over four billion people worldwide relying on it [13]. Othman et al. [57] investigated using ChatGPT as a tool to enhance the accessibility of existing webpages, while López-Gil et al.[50] explored LLMs’ ability to evaluate web accessibility success criteria. Aljedaani et al. [19] examined ChatGPT’s ability to generate accessible code and found that it often produces code with accessibility issues. However, their study did not compare ChatGPT’s performance against human-written code in terms of accessibility, nor did they propose methods for improving the accessibility of LLM-generated code. This leaves a gap in understanding how LLM-generated code compares to human-authored code and what strategies could enhance its accessibility. In this paper, we aim to fill this gap by comparing the accessibility of LLM-generated code with that of human-authored code for the web and answer the following research questions, among others: RQ1: Do LLMs generate more accessible code than humans? We first assess the current state of accessibility violations in code generated by LLMs. To do this, we select ten real-world web projects and regenerate key files affecting the User Interface (UI) of each project using two LLMs: GPT-4o [56], and Qwen2.5-Coder-32B- Instruct-AWQ [38]. We then analyze the accessibility of these regenerated websites using IBM Equal Access Accessibility Checker [9] and QualWeb Web Accessibility Evaluator [14]. Finally, we compare accessibility violations in the original implementations of websites with those in their recreated versions using LLM-generated code, RQ2: Do advanced prompting techniques help LLMs generate more accessible code? Next, to investigate the LLMs’ capability of generating accessible code, we implement three prompting techniques: Zero-Shot, Few- Shot, Self-Criticism [70]. These techniques are employed in the code generation phase to improve the accessibility of LLM-generated code. We evaluate the accessibility of the websites regenerated using these prompting techniques and compare the accessibility violations. RQ3: Can LLMs generate more accessible code by incorporating accessibility evaluation results into the code generation process?
Related work. Studies on web accessibility aim to provide access to all users, regardless of disabilities [25, 36]. This includes research on frameworks [22, 37, 54, 65] designed to support accessible web development and adaptive user interfaces [28, 62] that adjust to users’ varying needs. Additionally, research has focused on design aspects [31, 33, 39, 41, 66] to create inclusive and user-friendly web experiences for individuals with disabilities. Evaluation techniques and tools for web accessibility have been actively investigated. The most widely recognized guideline is WCAG [17], an international standard for making the web accessible to people with disabilities. WCAG is structured into principles, guidelines, success criteria, and techniques to address various disabilities. Tools like IBM Equal Access Accessibility Checker [9], QualWeb [14], WAVE [16], and AXE Accessibility Checker [7] automatically evaluate website compliance, identifying issues such as low contrast, missing alt text, and improper heading structures. Researchers have assessed the accessibility of websites, including those in education [20, 25, 53] and government [18, 58, 76], highlighting widespread non-compliance and areas for improvement.
2.2 Large Language Models for Code Generation The notable performance of LLMs in code-related tasks has impacted software development process. General purpose LLMs such as GPT-4o [56], DeepSeek-R1 [29], Llama3 [4] have been trained on large corpora, with the purpose of using them for various natural language tasks. These models are not only adept at processing natural language but also demonstrate strong capabilities in coderelated tasks. For tasks specifically involving code, specialized LLMs like Qwen2.5-Coder [38] and Copilot [3] have been trained on programming languages, making them skillful in code-related tasks including code generation [40, 45, 49, 51, 63, 64, 77]. LLMs demonstrate even more significant performance when combined with advanced prompting techniques like Few-Shot [23] and ReAct [75], or when fine-tuned for specific coding tasks [61]. These approaches enhance their ability to tackle a wide range of code-related challenges. Similar to other software engineering tasks, code generation performance has seen significant improvements through the effective use of prompting techniques or fine-tuning methods [23, 61]. Given the impressive performance of LLMs in code generation, evaluating the quality of their output is crucial to ensure reliability in software development. While LLMs can produce functionally correct code, studies have shown they fall short of expert-level efficiency [27, 60]. Research on LLM-generated code security has uncovered issues, with 29.6% of code snippets from GitHub Copilot containing vulnerabilities [34].
Method. In this paper, we first investigate the accessibility of LLM-generated web code and then apply advanced prompting techniques to improve LLMs’ ability to produce accessible code. Finally, we propose FeedA11y, a novel technique that mitigates accessibility violations during code generation by leveraging accessibility evaluation results. This section details our methodology, summarized in Figure 1.
Bi et al. [24] found that approximately 70% of selected GitHub projects reported accessibility issues, with the majority related specifically to UI design elements such as color usage and layout navigation, particularly in the application software domain (72.7%). Motivated by these findings, we focus our accessible code generation efforts explicitly on UI components. We selected ten active, real-world web projects with interactive UIs, as shown in Table 1. We followed a similar criteria from the prior work [42] to avoid toy or non-representative examples:
• Provides an actual website with UI. • Provides a GitHub repository for the website. • The GitHub repository has more than 50 stars. • The GitHub repository has more than 20 contributors. • The latest commit occurred no later than January 2025. To investigate the accessibility of LLM-generated code, we focused on files responsible for rendering UI elements on webpages. We identified UI-related files using two criteria: (1) common UI file extensions (e.g., ‘.html’, ‘.js’, and ‘.css’), and (2) the presence of HTML tags or UI-related code snippets (e.g., ‘document.getElementById’, ‘innerHTML’, ‘background:’, ‘font:’). A complete list is available in our replication package [5]. Table 1 summarizes the collected files, including the total number of UI-related files, those successfully used for rendering (“Final size”), and the analysis sample (“Sampled size”) selected with 90% confidence and 10% margin of error.
With the list of UI-related files obtained in Section 3.1, we needed to generate code that could be compared with human-written code for accessibility evaluation. This presented a methodological challenge: we needed to provide specifications to the LLMs, but formal specifications for these files were unavailable. To address this, we employed a two-step approach: first generating code summaries to serve as proxy specifications, then using these summaries to regenerate the code with different LLM instances. This process aligns with Wei et al. [73], who explored the duality between Code Summarization (CS) and Code Generation (CG), demonstrating that the output of CS can serve as the input for CG, and vice versa. By using separate instances of the same LLM for summarization and generation, we ensured that the LLM responsible for code generation did not have the original code within its context window. This prevented it from simply memorizing and reproducing the source code, forcing it to rely solely on the summarized information for regeneration. Below, we detail each step of this pipeline. When implementing our code generation pipeline, we needed to determine the optimal granularity for code generation. To regenerate code files, we first attempted a file-level approach, where we generated a summary of the entire file and used it as input to regenerate the code. However, this method resulted in a significant number of files being filtered out during rendering due to functional errors and dependency issues, leading to incorrect or incomplete outputs. To improve code generation accuracy and mitigate rendering issues with reconstructed code, we adopted a block-level approach. In our block-level approach, we first parsed the files into blocks based on their structure. We ensured that each code block contained meaningful content by leveraging structural elements. Specifically, for HTML files, we parsed based on structural tags as described in MDN Web Docs [15]. Each block encompassed the content within a high-level structural tag, such as <section>, <header>, <nav>, <main>, or a top-level <div>, ensuring that the segmentation retained meaningful sections of the document.
Discussion. and Implications.. The superior performance of LLMs, particularly in basic accessibility concerns such as contrast and alternative text issues, suggests a promising opportunity for automation and efficiency gains in web development workflows. These models could be effectively employed to handle routine accessibility corrections, thereby allowing human developers to focus their attention on more complex accessibility considerations. Nevertheless, the evident difficulties in managing intricate ARIA attributes highlight an essential limitation of current LLMs—the lack of nuanced understanding of complex semantic requirements. This reinforces the importance of maintaining human oversight and suggests potential improvements in LLM training or prompt engineering specifically targeted at complex ARIA semantics. Practitioners and researchers should leverage these insights to prioritize complementary approaches, blending AI-generated drafts with expert validation, ensuring high accessibility standards without distorting the original meaning or structure of the web content.
Discussion and Implications. Although structured prompting can effectively address certain basic accessibility issues, such as color contrast and alternative text descriptions, the inadvertent introduction of new ARIA-related violations reveals inherent limitations in explicit prompting. These results suggest that, despite their promise, prompting techniques must be cautiously designed to avoid overly rigid instructions that ignore context-specific constraints. Future work should consider developing more nuanced prompting approaches that dynamically adapt instructions based on contextual information to minimize unintended accessibility violations.
Discussion and Implications. These results underscore the effectiveness of leveraging evaluation-driven feedback within the code generation process to systematically reduce common accessibility violations. However, the persistent challenges with nuanced ARIA constraints, as well as accessibility issues related to semantic correctness (e.g., improper use of ARIA roles or missing landmark elements) and interactive behavior (e.g., inaccessible keyboard navigation or focus management), imply that evaluation-driven approaches alone are insufficient for managing all aspects of accessibility, particularly those involving complex semantics. Future enhancements could combine feedback-driven methods with specialized prompting techniques focusing on ARIA guidelines to improve accessibility outcomes.
Conclusion. In this paper, we systematically evaluated the accessibility of LLMgenerated web code compared to human-written code across realworld projects. Our findings show that LLMs–particularly GPT- 4o and Qwen2.5-Coder–often produce more accessible code than humans. While advanced prompting strategies (Zero-Shot, Few- Shot, Self-Criticism) improved accessibility, they also introduced new issues, especially with ARIA attribute uniqueness. To address these gaps, we introduced FeedA11y, a ReAct-based technique that uses accessibility feedback to refine code iteratively, outperforming all other methods. Future work should focus on targeted strategies and training to help LLMs consistently generate fully accessible web content. We provide the source code and datasets that were used in our experiments on the companion website [5].
Limitations. 5 THREATS TO VALIDITY While we employed rigorous methodological approaches in our study, we acknowledge certain considerations regarding validity. Construct Validity: Our use of inaccessibility rate as the primary metric poses certain limitations. Although it enables practical comparisons by measuring the proportion of elements with accessibility violations, it treats all violations equally, regardless of their severity or user impact. To address this, we provided a detailed breakdown of violation types and associated WCAG principles. Additionally, we employed both AChecker and QualWeb to mitigate tool-specific biases. However, this metric does not fully reflect the real user experience, which future work could address through studies involving users with disabilities. Internal Validity: To prevent information leakage between summarization and code generation, we employed separate LLM instances for each task. Additionally, we ran a data leakage experiment using projects released after the LLMs’ knowledge cutoff dates to ensure no prior exposure. To mitigate subjectivity in manual webpage consistency verification, two authors independently evaluated outputs using predefined criteria and resolved discrepancies through a negotiated agreement process. External Validity: Our findings may not generalize beyond this study’s LLMs and web projects.
Lines of inquiry this paper opens 24
Research framings built by reading the notes related to this paper — the questions it feeds into.
Can visual rendering-based rewards effectively improve code and layout quality?- How does code asymmetry break DOM-based evaluation of generated web interfaces?
- Can Chamfer Distance and code validity capture whether designs match an engineer's intent?
- What specific ARIA constraints remain difficult for feedback-driven code generation?
- How does the accessibility tree representation limit both code generation and evaluation?
- Can combining evaluator feedback with specialized ARIA prompting close the remaining gap?
- Can code generation tools learn ARIA attributes from specification summaries?
- What are the five textual correctness criteria MSRL uses for code validation?
- Should layout evaluation capture rendering artifacts like element overlap?
- Can bounding-box signals prevent visual flaws better than code APIs?
- What other code generation tasks face similar uniform loss limitations?
- Do static and build checks catch structural failures before aesthetic scoring?
- Can helper libraries reduce complexity of generating executable programs from text?
- Why do LLMs introduce new ARIA violations when given explicit accessibility prompts?
- Why do automated accessibility checkers miss complex semantic requirements?
- Why do LLMs succeed at element-level accessibility fixes but fail at document-wide constraints?
- Why do multimodal LLMs fail at identifying UI elements and respecting layout constraints simultaneously?