Accessibility, Forms & Web Best Practices
Good web design is about more than appearance. A website should be understandable, readable, and usable by as many people as possible. This week, you will learn practical ways to improve accessibility and build a simple, well-structured contact form using HTML and CSS.
01 / What You Will Learn
Over the past several weeks, you have learned to structure content with HTML, style it with CSS, and make layouts responsive. Now you will consider how people experience your website in different ways.
Design for accessibility
Learn how structure, text, color, and navigation affect the experience of different users.
Write meaningful HTML
Use headings, landmarks, descriptive links, and image alternatives to communicate meaning.
Build an HTML form
Create labeled fields, a dropdown menu, a message area, and a submit button.
Test usability
Check keyboard navigation, readability, contrast, and the overall user experience.
02 / What Is Web Accessibility?
Web accessibility means designing and developing websites so people with different abilities can perceive, understand, navigate, and interact with the content.
Some people navigate with a keyboard rather than a mouse. Some use screen readers that announce page content aloud. Others may have low vision, color-vision differences, hearing disabilities, or difficulty using small interactive controls.
Visual access
Use readable text, sufficient contrast, useful alternative text, and a clear heading structure.
Keyboard access
Make sure people can reach and use interactive elements without relying on a mouse.
Clear communication
Write meaningful link text, provide instructions, and explain form fields and errors clearly.
Accessibility is not achieved by one CSS property or a single testing tool. It comes from a series of thoughtful design and development decisions.
03 / Use HTML to Communicate Meaning
HTML elements provide structure and meaning. Choosing the correct element helps browsers and assistive technologies interpret the page.
<header>
<h1>My Design Portfolio</h1>
</header>
<nav aria-label="Main navigation">
<a href="#work">View my work</a>
<a href="#about">About me</a>
<a href="#contact">Contact</a>
</nav>
<main>
<section id="work">
<h2>Selected Work</h2>
<p>A collection of recent projects.</p>
</section>
</main>
<footer>
<p>© 2026 My Portfolio</p>
</footer>
These elements describe the roles of different page areas:
- <header> introduces a page or section.
- <nav> identifies a navigation area.
- <main> contains the page’s primary content.
- <section> groups related content.
- <footer> contains closing or supplementary information.
04 / Images and Alternative Text
Alternative text, often called alt text, communicates the purpose or meaningful content of an image to people who may not be able to see it. It can also appear when an image fails to load.
<img src="abstract-painting.jpg"
alt="Abstract painting with layered red and blue brushstrokes">
Write alt text that communicates the image’s relevant content in context. You do not need to begin with “Image of” or “Picture of.”
<img src="decorative-line.png"
alt="">
If an image is purely decorative and does not add information, an empty alt attribute tells assistive technology it can be skipped. Do not omit the alt attribute entirely.
Practice: improve the description
Too vague
“Photo”
This does not communicate what the image shows.
More useful
“Black-and-white photograph of a person walking through a crowded city street.”
This describes meaningful visual information.
For artwork, consider what a person needs to understand about the image. Describe important subjects, actions, and visual details without turning the alt text into an unnecessarily long artist statement.
05 / Color Contrast and Readability
Color helps establish a visual identity, but text must remain readable against its background. Pale text on a pale background or dark text on a dark background can make a page difficult to use.
Dark text on a light background.
Strong contrast
Text and its background are easy to distinguish.
Light text on a light background.
Weak contrast
Some readers may struggle to distinguish the text.
As a general WCAG guideline, normal-sized text should have a contrast ratio of at least 4.5:1 against its background. Large text has a lower minimum of 3:1. These are useful starting points for evaluating your color choices.
body {
background-color: #ffffff;
color: #172033;
}
.primary-button {
background-color: #183b91;
color: #ffffff;
}
Use a contrast checker to evaluate your chosen foreground and background colors. Do not rely on color alone to communicate meaning: pair color with text, labels, icons, or other visual cues.
06 / Links, Buttons, and Keyboard Navigation
Interactive elements should communicate what they do and be usable without a mouse.
<!-- Less descriptive -->
<a href="portfolio.html">Click here</a>
<!-- More descriptive -->
<a href="portfolio.html">View my design portfolio</a>
Descriptive links make it easier for people to understand where a link leads, especially when they encounter links outside the surrounding paragraph.
<!-- Use a link to navigate to another page -->
<a href="about.html">About me</a>
<!-- Use a button to perform an action -->
<button type="button">Show details</button>
Browsers provide built-in keyboard behavior for links, buttons, and standard form controls. Avoid removing the visible focus outline unless you replace it with an equally clear indicator.
Keyboard test
- Click the preview, then press Tab to move between interactive elements.
- Look for a visible focus indicator showing which element is selected.
- Press Shift + Tab to move backward.
- Use Enter or Space as appropriate to activate the focused link or button.
07 / Introduction to HTML Forms
Forms allow visitors to enter information. You see them on contact pages, event registrations, feedback pages, surveys, and many other websites.
A basic form can use several HTML elements:
<form>
Groups the controls that collect user input.
<label>
Identifies a field so users understand what information belongs there.
<input>
Collects short information such as a name or email address.
<textarea>
Provides space for a longer message.
Connect labels to fields
A label’s for attribute should match the field’s id. This relationship helps users, including people using screen readers, identify each field.
<label for="name">Your name</label>
<input type="text" id="name" name="name">
Notice that both the label and the input use the same identifier, name. If the identifiers do not match, the label may not be correctly associated with its field.
08 / Build an Accessible Contact Form
In this guided example, you will create a contact form for a personal portfolio. It includes a name field, an email field, a reason for contacting you, a message area, and a submit button.
<section class="contact-section" id="contact">
<h2>Get in Touch</h2>
<p>Have a question or project idea? Send me a message.</p>
<form action="#" method="post">
<div class="form-field">
<label for="contact-name">Your name</label>
<input type="text" id="contact-name"
name="name" autocomplete="name" required>
</div>
<div class="form-field">
<label for="contact-email">Email address</label>
<input type="email" id="contact-email"
name="email" autocomplete="email" required>
</div>
<div class="form-field">
<label for="contact-reason">Reason for contacting me</label>
<select id="contact-reason" name="reason">
<option value="">Choose an option</option>
<option value="project">Project inquiry</option>
<option value="collaboration">Collaboration</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-field">
<label for="contact-message">Your message</label>
<textarea id="contact-message" name="message"
rows="5" required></textarea>
</div>
<button type="submit">Send Message</button>
</form>
</section>
What the attributes do
- type=”text” creates a field for short text.
- type=”email” provides a field intended for an email address and enables basic browser validation.
- required asks the browser to prevent submission when a required field is empty.
- autocomplete helps browsers recognize common information fields.
- rows=”5″ gives the message area an initial height of five text rows.
- type=”submit” makes the button submit the form.
09 / Style the Form with CSS
Accessible forms can still have a strong visual identity. Use clear spacing, readable text, visible field boundaries, and a distinct button. The following CSS creates a simple layout that can adapt to narrower screens.
.contact-section {
max-width: 700px;
margin: 40px auto;
padding: 24px;
background: #f4f6fa;
border-radius: 12px;
}
.form-field {
margin-bottom: 20px;
}
.form-field label {
display: block;
font-weight: 700;
margin-bottom: 6px;
}
.form-field input,
.form-field select,
.form-field textarea {
width: 100%;
padding: 12px;
font: inherit;
color: #172033;
background: #ffffff;
border: 1px solid #68748a;
border-radius: 6px;
}
.form-field textarea {
resize: vertical;
}
.contact-section button {
padding: 12px 20px;
border: 0;
border-radius: 6px;
background: #183b91;
color: #ffffff;
font: inherit;
font-weight: 700;
cursor: pointer;
}
.contact-section button:hover {
background: #10285f;
}
.contact-section button:focus-visible {
outline: 3px solid #2855d9;
outline-offset: 3px;
}
@media (max-width: 500px) {
.contact-section {
padding: 16px;
margin: 20px auto;
}
}
Try changing the background color, button color, border radius, and spacing. Keep enough contrast between text and its background, and make sure keyboard focus remains visible.
10 / In-Class Assignment: Accessible Contact Page
Create a single-page contact page for a creative portfolio, student organization, fictional studio, or project of your choice. The goal is to combine the HTML structure you have learned with thoughtful usability and accessible form design.
Page structure
Add a header, a main section, a descriptive heading, and a brief introduction to the contact page.
Contact form
Include a name field, email field, reason dropdown, message area, and submit button.
Visual design
Style the form using CSS. Establish a clear hierarchy with readable type, spacing, and contrast.
Required elements
- Use semantic HTML to organize the page.
- Give each form field a visible label connected through matching for and id values.
- Use appropriate input types and include required fields where needed.
- Include descriptive alt text if you add informative images.
- Use readable color contrast.
- Include a visible keyboard focus indicator.
- Make the layout responsive on mobile and desktop.
- Test the form controls using your keyboard.
Suggested workflow
- Plan the page. Decide who the page is for and what information visitors need to provide.
- Build the HTML. Start with the page structure and labeled form fields before adding decorative styles.
- Apply CSS. Use consistent spacing, typography, borders, and colors to create a clear visual hierarchy.
- Check accessibility. Test labels, contrast, heading order, link descriptions, and keyboard focus.
- Test responsiveness. Preview the page at narrow and wide screen sizes and correct any overflow.
- Revise the design. Improve any confusing labels, cramped spacing, or unclear instructions.
11 / Independent Practice
Expand your contact page into a small, more complete website experience. You can adapt the page to fit a personal portfolio, creative business, exhibition, student club, or fictional brand.
Choose at least two improvements beyond the basic requirements:
- Add a short FAQ section using semantic headings.
- Add a project inquiry category that makes sense for your subject.
- Improve the visual hierarchy with a consistent type scale and spacing system.
- Check your chosen text and background colors with a contrast checker.
- Add a descriptive link back to your portfolio or home page.
- Improve the page’s mobile layout and test the keyboard focus order.
12 / Testing Checklist
Before you submit, test the page from the perspective of someone visiting it for the first time.
- Can visitors quickly understand the purpose of the page?
- Does the page have a clear heading structure?
- Can every form field be identified without relying on placeholder text?
- Can you move between controls using the keyboard?
- Is the current keyboard focus clearly visible?
- Are text and background colors easy to distinguish?
- Do informative images have appropriate alternative text?
- Are link descriptions meaningful outside their surrounding paragraphs?
- Does the layout work on both mobile and desktop screens?
- Have you avoided suggesting that the form sends a message when it has no working submission service?
13 / What to Submit
Submit the following through the course’s designated submission area:
- Your CodePen URL.
- A screenshot of your completed contact page.
- A screenshot showing the page at a narrow/mobile width.
- A short reflection of approximately 100–150 words describing two accessibility decisions you made and one change you made after testing.
How your work will be evaluated
- HTML structure: Appropriate semantic elements and logical headings.
- Form usability: Clear labels, suitable field types, and understandable instructions.
- Accessibility: Attention to contrast, keyboard access, image alternatives, and meaningful links.
- CSS design: Consistent typography, spacing, and visual hierarchy.
- Responsive behavior: A layout that remains usable at different screen widths.
- Reflection: An explanation of your design choices and testing process.
14 / Key Terms
Accessibility
Designing and developing content so people with different abilities can use it.
Semantic HTML
HTML elements that communicate the meaning and role of the content they contain.
Alt text
A text alternative that communicates the relevant content or purpose of an image.
Color contrast
The difference in brightness between foreground content and its background.
Form label
Text that identifies a form control and helps explain what information belongs in it.
Keyboard focus
The current interactive element selected when navigating with a keyboard.
15 / Online Resources
Use these resources to review the concepts and explore examples from established web standards organizations.
W3C Web Accessibility Initiative
Practical tutorials covering page structure, images, navigation, forms, and accessible interactions.
W3C: Developing for Web Accessibility
A beginner-friendly overview of accessible images, labels, semantic markup, and keyboard access.
MDN: How to Structure a Web Form
Learn how form elements, labels, fieldsets, and legends help make forms more usable and accessible.