Your Gateway to Web Accessibility

One of the most important aspects of website accessibility is color contrast, as it directly affects the readability and usability of your web content for users with varying visual abilities. Web Content Accessibility Guidelines (WCAG) set standards for color contrast ratios to guarantee a positive user experience for everyone. Aspose.HTML for .NET provides detailed color contrast checking, allowing you to identify specific elements that may need adjustment. Seamlessly integrate web accessibility validation features into your web applications, ensuring WCAG compliance!

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





How to check color contrast in C#

If you want to check the website for compliance with WCAG guidelines programmatically in C#, the Aspose.HTML for .NET provides the Aspose.Html.Accessibility namespace, which is for all web accessibility-related manipulations and checks. The following C# code is designed to validate a web page against specific color accessibility criteria, and you will receive a report of issues related to those rules.


C# code to check color accessibility

using Aspose.Html;
using Aspose.Html.Accessibility;
...

    // Prepare a path to a source HTML file
    string documentPath = Path.Combine(DataDir, "check-color.html");

    // Initialize a webAccessibility container
    WebAccessibility webAccessibility = new WebAccessibility();

    // Get Principle "1.Perceivable" by code "1" and get guideline "1.4"
    var guideline = webAccessibility.Rules.GetPrinciple("1").GetGuideline("1.4");

    // Get criterion by code, for example 1.4.3
    var criterion143 = guideline.GetCriterion("1.4.3");

    // Get criterion by code, for example 1.4.6
    var criterion146 = guideline.GetCriterion("1.4.6");

    // Create an accessibility validator, pass the found guideline as parameters and specify the full validation settings
    var validator = webAccessibility.CreateValidator(new IRule[] { criterion143, criterion146 }, ValidationBuilder.All);

    using (var document = new HTMLDocument(documentPath))
    {
        var validationResult = validator.Validate(document);
        if (!validationResult.Success)
        {

            Console.WriteLine(validationResult.SaveToString());

        }
    }



Check Color Accessibility – Key Features

Aspose.HTML for .NET provides a powerful set of classes and methods to facilitate color contrast accessibility checks in your C# projects.

  1. Initializing the Web Accessibility Container. Use the WebAccessibility() constructor to create an instance of the WebAccessibility class.
  2. Getting Guideline and Criterion. Specify a guideline to focus on a specific aspect of web accessibility. Call the GetPrinciple() method of the AccessibilityRules class and the GetGuideline() method of the Principle class to get the required principle by code from WCAG against which you want to check the document.
  3. Creating an Accessibility Validator. Call the CreateValidator() method to create a validator object.
  4. HTML Document Validation. Use the HTMLDocument class to initialize an HTML document for validation. You can load HTML from a file or URL. Use the Validate() method to check the HTML content against the selected criterion. The result is stored in the validationResult variable.
  5. Handling Validation Results. The Aspose.Html.Accessibility.Results namespace contains classes that describe the results of rule validation. The validation process generates detailed results, providing specific information about the success and failure of rule checks.



Why Choose Aspose.HTML for .NET

  1. Aspose.HTML for .NET provides detailed color contrast checking, allowing you to identify specific elements that may need adjustment.
  2. The library integrates easily with your C# projects, providing an efficient workflow for implementing color contrast checks. Use the power of color accessibility checks without sacrificing performance.
  3. Continuous library updates will keep you ahead of the curve and compliant with regular updates to accessibility standards.
  4. Our support team is always ready to assist you. If you have questions, encounter difficulties, or need advice, please contact Free Support , and we will be happy to help.



Check Color Contrast using C# – Documentation

The Web accessibility – How to Check documentation chapter offers a detailed guide on validating an HTML document according to WCAG compliance. 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 Сolor Сontrast Accessibility article, you will learn how to check color contrast accessibility using C# and make your web content easy to read for all users.



Color Contrast Accessibility – Online App

Aspose.HTML offers the Color Contrast Accessibility application – an online web accessibility testing tool that scans web pages and validates color contrast against the WCAG compliance. It will also provide you with recommendations on how you can offer users a more accessible online experience.


Text “Color Contrast Accessibility – Online App”

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!