Ensuring web accessibility is essential for creating inclusive digital experiences. With this tool, you can upload an HTML file to analyze its compliance with WCAG (Web Content Accessibility Guidelines). The system will scan your file for common accessibility issues, such as missing alternative text, poor keyboard navigation, improper heading structures, and ARIA implementation. After the analysis, you'll receive a detailed report with actionable recommendations to improve accessibility, helping you build a more inclusive and user-friendly website.
Ensure you have the following installed before proceeding:
- PHP (version 8.2 or later recommended)
- Composer
- Nginx or Apache (for serving the application)
- Docker (optional for containerized development)
Clone the repository and install dependencies:
cd wcag_checker
# Install PHP dependencies
composer install
Copy the example environment file and set up the required configurations:
cp .env.example .env
Generate the application key:
php artisan key:generate
Start the development server:
php artisan serve
Alternatively, if using Docker:
./vendor/bin/sail up
The application should now be accessible at http://localhost:8000.
Run the test suite:
php artisan test
For production deployment, set up your web server:
php artisan config:cache
php artisan route:cache
php artisan view:cache
Ensure the web server points to the public/
directory.
The WCAGAnalyzer
service is designed to analyze HTML documents for Web Content Accessibility Guidelines (WCAG) compliance. It features a sophisticated, modular architecture:
-
Parser Factory: The
HtmlParserFactory
provides flexibility by allowing dynamic selection of HTML parsers (CustomHtmlParser
orSymfonyHtmlParser
). -
Rules Pipeline: Utilizes Laravel's
Pipeline
to systematically process theWCAGAnalyzer
instance through multiple WCAG rules:MissingAltRule
MissingLabelRule
HeadingHierarchyRule
MetaViewportRule
KeyboardNavigation
-
AI-Enhanced Suggestions: Integrates Gemini AI to provide intelligent, actionable improvements for detected accessibility issues, enhancing the analysis with context-aware recommendations.
-
Scoring System: Implements a comprehensive scoring mechanism that calculates accessibility compliance by considering base score, issue impact, and specific penalties.
The scoring algorithm is designed to provide a nuanced evaluation of web accessibility:
-
Element Analysis:
- Extracts and analyzes all HTML elements
- Focuses on essential elements:
img
,a
,input
,button
, headings, forms, and tables
-
Base Score Calculation:
- 0 essential elements: Base score = 40
- 1-2 essential elements: Base score = 50
- 3-4 essential elements: Base score = 60
- 5+ essential elements: Base score = 100
-
Severity-Based Penalty System:
- High severity issues: -20 points per issue
- Medium severity issues: -10 points per issue
- Low severity issues: -5 points per issue
-
Dynamic Impact Adjustments:
- For pages with less than 5 total elements and existing issues, the impact is increased by 50%
- Minimal content with no essential accessibility features caps the final score at 40
-
Score Calculation:
$score = max(0, min(100, $baseScore - $issueImpact));
The analyzer now incorporates Gemini AI to:
- Refine issue descriptions
- Generate more actionable suggestions
- Provide context-aware improvements for accessibility challenges
Severity is determined based on WCAG 2.1 guidelines, where violations of critical accessibility requirements are assigned higher severity levels:
-
High Severity (Critical): Issues that severely impact accessibility and prevent users from accessing content.
- 1.1.1 Non-text Content (Missing alt attributes on images, inaccessible CAPTCHA, missing text alternatives)
- 2.1.1 Keyboard (Elements that cannot be accessed via keyboard)
- 2.2.2 Pause, Stop, Hide (Content that auto-updates without user control)
-
Medium Severity (Serious): Issues that significantly affect usability but do not completely block access.
- 1.3.1 Info and Relationships (Incorrect heading hierarchy, missing landmarks)
- 1.4.3 Contrast (Minimum) (Insufficient text contrast)
- 2.4.7 Focus Visible (No visible focus indicators)
-
Low Severity (Minor): Issues that cause inconvenience but do not significantly hinder accessibility.
- 3.1.1 Language of Page (Missing
lang
attribute) - 4.1.2 Name, Role, Value (Missing ARIA attributes for better assistive technology support)
- 2.5.3 Label in Name (Inconsistent labeling of interactive elements)
- 3.1.1 Language of Page (Missing
By classifying violations according to these WCAG principles, the scoring system ensures an accurate reflection of the accessibility impact.
- Modular rule-based analysis
- Flexible HTML parser support
- AI-enhanced issue recommendations
- Comprehensive accessibility scoring
- Granular severity classification
- Gemini AI API KEY
- Expanded rule set
- More detailed AI suggestions
- Enhanced scoring granularity
Developed by Musah Musah.