To ensure that a website like MedlinePlus complies with the U.S. Web Design System (USWDS), you need to follow the guidelines and components provided by USWDS. USWDS is a design system that provides a set of reusable components and styles to help create consistent, accessible, and responsive web applications.
Here are some general steps and HTML code snippets to help you fix non-USWDS compliant code:
- Include USWDS CSS and JS: First, you need to include the USWDS CSS and JavaScript files in your HTML.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MedlinePlus</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@uswds/uswds@3.1.0/dist/css/uswds.min.css">
<script src="https://cdn.jsdelivr.net/npm/@uswds/uswds@3.1.0/dist/js/uswds.min.js"></script>
</head>
<body>
<!-- Your content goes here -->
</body>
</html>
- Use USWDS Components: Replace non-compliant HTML elements with USWDS components. For example, if you have a non-compliant button, you can replace it with a USWDS button.
<!-- Non-compliant button -->
<button class="btn btn-primary">Click Me</button>
<!-- USWDS compliant button -->
<button class="usa-button">Click Me</button>
- Use USWDS Grid System: Ensure that your layout uses the USWDS grid system for consistent and responsive design.
<div class="usa-grid">
<div class="usa-width-one-whole">
<h1>Welcome to MedlinePlus</h1>
</div>
<div class="usa-width-one-half">
<p>This is a sample paragraph.</p>
</div>
<div class="usa-width-one-half">
<p>This is another sample paragraph.</p>
</div>
</div>
- Use USWDS Forms: Replace non-compliant forms with USWDS forms.
<!-- Non-compliant form -->
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<button type="submit">Submit</button>
</form>
<!-- USWDS compliant form -->
<form class="usa-form">
<div class="usa-form-group">
<label class="usa-label" for="name">Name</label>
<input class="usa-input" id="name" name="name" type="text">
</div>
<button class="usa-button" type="submit">Submit</button>
</form>
- Use USWDS Typography: Ensure that your typography follows USWDS guidelines.
<!-- Non-compliant typography -->
<h1>Welcome to MedlinePlus</h1>
<p>This is a sample paragraph.</p>
<!-- USWDS compliant typography -->
<h1 class="usa-heading">Welcome to MedlinePlus</h1>
<p class="usa-paragraph">This is a sample paragraph.</p>
- Accessibility: Ensure that all elements are accessible. USWDS provides guidelines and components that are accessible by default.
<!-- Non-compliant accessible element -->
<a href="#content">Skip to content</a>
<!-- USWDS compliant accessible element -->
<a class="usa-skipnav" href="#main-content">Skip to main content</a>
- Review and Test: After making these changes, review the website to ensure that it complies with USWDS guidelines. Use tools like Lighthouse in Chrome DevTools to test accessibility and performance.
Example of a Complete Page
Here is an example of a complete HTML page that incorporates USWDS components:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MedlinePlus</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@uswds/uswds@3.1.0/dist/css/uswds.min.css">
<script src="https://cdn.jsdelivr.net/npm/@uswds/uswds@3.1.0/dist/js/uswds.min.js"></script>
</head>
<body>
<a class="usa-skipnav" href="#main-content">Skip to main content</a>
<header class="usa-header">
<div class="usa-nav-container">
<div class="usa-navbar">
<div class="usa-logo" id="logo">
<em class="usa-logo-text">MedlinePlus</em>
</div>
<button class="usa-menu-btn">Menu</button>
</div>
<nav aria-label="Primary navigation" class="usa-nav">
<button class="usa-nav-close">
<img src="https://cdn.jsdelivr.net/npm/@uswds/uswds@3.1.0/dist/img/usa-icons/close.svg" role="img" alt="close">
</button>
<ul class="usa-nav-list">
<li class="usa-nav-item">
<a href="#" class="usa-nav-link">Home</a>
</li>
<li class="usa-nav-item">
<a href="#" class="usa-nav-link">About</a>
</li>
<li class="usa-nav-item">
<a href="#" class="usa-nav-link">Contact</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main-content" class="usa-grid">
<div class="usa-width-one-whole">
<h1 class="usa-heading">Welcome to MedlinePlus</h1>
</div>
<div class="usa-width-one-half">
<p class="usa-paragraph">This is a sample paragraph.</p>
</div>
<div class="usa-width-one-half">
<p class="usa-paragraph">This is another sample paragraph.</p>
</div>
<form class="usa-form">
<div class="usa-form-group">
<label class="usa-label" for="name">Name</label>
<input class="usa-input" id="name" name="name" type="text">
</div>
<button class="usa-button" type="submit">Submit</button>
</form>
</main>
<footer class="usa-footer">
<div class="usa-footer-primary-section">
<div class="usa-grid">
<div class="usa-footer-logo-section">
<img class="usa-footer-primary-content-logo" src="https://cdn.jsdelivr.net/npm/@uswds/uswds@3.1.0/dist/img/uswds-logo.svg" alt="USWDS Logo">
</div>
<div class="usa-footer-contact-section">
<div class="usa-footer-contact-links">
<a class="usa-link" href="#">Contact Us</a>
<a class="usa-link" href="#">Privacy Policy</a>
</div>
</div>
</div>
</div>
</footer>
</body>
</html>
This example includes a header, main content area, and footer, all using USWDS components and styles. You can customize it further based on the specific requirements of the MedlinePlus website.