Your Gateway to Web Accessibility
Aspose.HTML for .NET offers the Aspose.Html.Accessibility namespace that is dedicated to all aspects of web accessibility-related checks and manipulations. In this namespace, the AccessibilityValidator class serves as a helper class that can be used to check web content against WCAG rules , including principles, guidelines, and criteria. Learn how to incorporate web accessibility checks into your development workflow and elevate your web projects using Aspose.HTML for .NET!
First, make sure you have Aspose.HTML for .NET installed in your project. The installation process of this library is quite simple. Open the NuGet package manager, search for Aspose.HTML, and install. You may also use the following command from the Package Manager Console:
Install Aspose.HTML for .NET
Install-Package Aspose.HTML
Understanding the Accessibility Validator
- At the core of implementing web accessibility checks is the AccessibilityValidator class, which contains a Validate() method to check accessibility. The Validate() method checks the incoming document for compliance with the WCAG rules using the validator settings that were specified when the object was initialized.
- The ValidationBuilder class is used to customize the list of rules that the validator checks. The ValidationBuilder defines methods and provides concrete implementations of the configuration steps. For example, by using methods such as UseHTML(), UseCSS(), UseHighestLevel(), and more from the ValidationBuilder class, developers can customize the validation process to suit their specific needs.
- The ValidationResult class encapsulates the results of document validation, offering success status information and detailed results.
The following C# code snippet creates a webAccessibility
container, an accessibility validator, and checks the HTML document for WCAG compliance. For each unsuccessful rule, it prints details of specific criteria that did not meet the accessibility standards, including their code, success status, and description. After checking, printed output provides a full overview of accessibility issues detected in the HTML document:
C# code to use the Accessibility Validator
using Aspose.Html;
using Aspose.Html.Accessibility;
using Aspose.Html.Accessibility.Results;
...
// Initialize a webAccessibility container
var webAccessibility = new WebAccessibility();
// Create an accessibillity validator with static instance for all rules from repository that match the builder settings
var validator = webAccessibility.CreateValidator(ValidationBuilder.All);
string documentPath = Path.Combine(DataDir, "input.html");
// Initialize an object of the HTMLDocument class
using (var document = new HTMLDocument(documentPath))
{
// Check the document
ValidationResult validationResult = validator.Validate(document);
// Take a list of rules results
foreach (var ruleResult in validationResult.Details)
{
// List only unsuccessful rule
if (!ruleResult.Success)
{
// Print the code and description of the rule
Output.WriteLine("{0}:{1}", ruleResult.Rule.Code, ruleResult.Rule.Description);
// Print the results of all methods
foreach (ITechniqueResult ruleDetail in ruleResult.Results)
{
// Print the code and description of the criterions
StringBuilder str = new StringBuilder(string.Format("\n{0}: {1} - {2}",
ruleDetail.Rule.Code, ruleDetail.Success,
ruleDetail.Rule.Description));
Output.WriteLine(str.ToString());
}
}
}
}
Why Choose Aspose.HTML for .NET
- Aspose.HTML for .NET provides specialized features, сlasses, and methods of the Aspose.Html.Accessibility namespace designed explicitly for web accessibility validation. This allows developers to integrate accessibility checks into their applications seamlessly.
- Developers have the ability to customize and filter the rules that will be checked during the review process and can check HTML documents against a comprehensive set of rules or selective specific WCAG principles and criteria. This level of control is critical to tailoring website accessibility checks based on specific project requirements.
- The web accessibility validation process generates detailed results through the ValidationResult class, providing developers with specific information about successful and unsuccessful rule validations. This facilitates in-depth analysis and targeted improvements.
- Continuous library updates will keep you ahead of the curve and compliant with regular updates to accessibility standards.
- Aspose.HTML for .NET integrates seamlessly into your C# projects, allowing you to focus on developing without the need for a steep learning curve or complex setup.
Web Accessibility Check – Documentation
The Web Accessibility Check documentation chapter teaches how to check websites for WCAG compliance in C# programmatically. Having checked your website, web application, or any other HTML document, you can be sure that people with disabilities will be able to use it effectively. You can check website accessibility for all WCAG compliance or only meet specific criteria. Aspose.HTML for .NET helps you pass these checks.
In the Accessibility Validator article, you will learn about the AccessibilityValidator and ValidationBuilder classes, which you can use to check website accessibility against WCAG rules, such as principles, guidelines, and criteria.
Web Accessibility Checker – Online App
Aspose.HTML offers the Web Accessibility Checker – an online web accessibility testing tool that scans web pages and validates them for WCAG compliance. Get instant insights into your website’s compliance, allowing you to determine the extent of corrections needed and the gap between the website’s or HTML document’s current state and WCAG requirements. Use the Web Accessibility Checker in your browser to identify accessibility errors without limitations for free!
Other Supported Aspose.HTML for .NET API Features
Use the Aspose.HTML for .NET library to convert, merge, edit HTML, EPUB, MHTML, XHTML, MD documents, extract data from the web, and more!