A demonstration project showcasing a responsive, accessible HTML form styled with modern CSS Grid layout techniques. This project focuses on semantic HTML, accessibility, and clean, maintainable CSS — enhanced with light JavaScript for interactivity. No data is submitted; the form is purely for UI demonstration purposes.
The form.css
file applies a modern CSS Grid layout to the form, using media query range syntax to adapt from single-column to two-column layouts responsively. The styling includes:
grid-template-columns
withrepeat()
for responsive columns.- The
.full-width
utility spans elements across the full form width. - Selective use of Flexbox (e.g., checkbox/radio layouts) for simpler inline content.
- Enhanced form control appearance (uniform font, border radius, color scheme).
- Custom focus states, hover effects, and styling for required indicators.
- Nested selectors and
:has()
for clean component-based logic. - Respects accessibility and usability with consistent spacing and legible controls.
Built with vanilla ES6 JavaScript, focusing on modern syntax and browser APIs.
The JavaScript has been split into separate modules, improving code modularity:
form.js
: Prevents default form submission behavior to stop URL parameter generation and resets form fields after submission.
loader.js
: See Loader Git repositorytheme.js
: Handles theme toggling (light/dark mode) and local storage management.
The application includes a dark mode and light mode toggle:
- The current theme state is stored in local storage and applied automatically on page reload.
- Accessible buttons with appropriate ARIA attributes are used to improve usability.
Important
Remember to change const LOCAL_STORAGE_PREFIX
in js-modules/theme.js
to a unique identifier.
- All form inputs are associated with
label
elements usingfor
andid
attributes. - The
fieldset
andlegend
elements group related radio inputs semantically. - The telephone input uses
aria-describedby
for inline screen reader help. - Visual focus indicators are preserved for keyboard navigation.
- Inputs use
autocomplete
,inputmode
, andplaceholder
attributes for better mobile and screen reader support. required
fields are clearly marked with both visual indicators and HTML validation attributes.- The form is fully keyboard-navigable with tab and arrow keys.
The site is fully navigable using tab keys and up/down arrows.
The application has been tested on the following platforms and browsers:
- Operating System: Windows 10
- Browsers:
- Google Chrome
- Mozilla Firefox
- Microsoft Edge
The layout and functionality have been verified in both browser and device simulation views to ensure responsiveness and usability.
- Clone or download the repository to your local machine.
- Open the project folder and start a simple HTTP server (e.g., using
Live Server
in VS Code or Python'shttp.server
module). - Open the project in a modern browser (e.g., Chrome, Firefox, or Edge).