Profile Form Rows in HTML, CSS and vanilla JS
A copy-paste Profile Form Rows in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="example-profile-form-rows" data-dcl-layout="rail" data-dcl-scheme="light" aria-labelledby="example-profile-form-rows-title"><header><h2 id="example-profile-form-rows-title">Profile Form Rows</h2></header><div class="parts"><div><label for="example-profile-form-rows-field-0">Display name</label><input type="text" id="example-profile-form-rows-field-0" aria-describedby="example-profile-form-rows-hint-0"><p id="example-profile-form-rows-hint-0">Shown on your public profile.</p></div><div><label for="example-profile-form-rows-field-1">Team</label><input type="text" id="example-profile-form-rows-field-1" aria-describedby="example-profile-form-rows-hint-1"><p id="example-profile-form-rows-hint-1">Printed under your name.</p></div><div><label for="example-profile-form-rows-field-2">Time zone</label><input type="text" id="example-profile-form-rows-field-2" aria-describedby="example-profile-form-rows-hint-2"><p id="example-profile-form-rows-hint-2">Use a city or UTC offset.</p></div></div>
<script>
(() => {
const root = document.currentScript.closest(".example-profile-form-rows");
const instance = Array.from(document.getElementsByClassName("example-profile-form-rows")).indexOf(root);
if (instance > 0) {
const references = ["id", "aria-labelledby", "aria-controls", "aria-describedby", "for", "name"];
for (const element of [root, ...root.querySelectorAll("*")]) {
for (const attr of references) {
if (element.hasAttribute(attr)) element.setAttribute(attr, element.getAttribute(attr) + "--" + instance);
}
const href = element.getAttribute("href");
if (href && href.startsWith("#")) element.setAttribute("href", href + "--" + instance);
}
}
const preference = matchMedia("(prefers-color-scheme: dark)");
const apply = () => { root.dataset.dclScheme = preference.matches ? "dark" : "light"; };
preference.addEventListener("change", apply);
apply();
})();
</script></section>
<style>
.example-profile-form-rows { color: #11292f; background-color: #ffffff; color-scheme: light; }
.example-profile-form-rows a { color: #005c62; }
.example-profile-form-rows button, .example-profile-form-rows summary, .example-profile-form-rows input, .example-profile-form-rows select {
color: #11292f; background-color: #e4edef; border-color: #697f84;
}
.example-profile-form-rows button:hover, .example-profile-form-rows summary:hover, .example-profile-form-rows button[aria-selected="true"] {
color: #ffffff; background-color: #00535a;
}
.example-profile-form-rows dialog { color: #11292f; background-color: #ffffff; }
.example-profile-form-rows [data-note] { color: #11292f; background-color: #e4edef; }
.example-profile-form-rows :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.example-profile-form-rows[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; color-scheme: dark; }
.example-profile-form-rows[data-dcl-scheme="dark"] a { color: #8fe1da; }
.example-profile-form-rows[data-dcl-scheme="dark"] button, .example-profile-form-rows[data-dcl-scheme="dark"] summary, .example-profile-form-rows[data-dcl-scheme="dark"] input, .example-profile-form-rows[data-dcl-scheme="dark"] select {
color: #eff8f9; background-color: #1c3c44; border-color: #839fa5;
}
.example-profile-form-rows[data-dcl-scheme="dark"] button:hover, .example-profile-form-rows[data-dcl-scheme="dark"] summary:hover, .example-profile-form-rows[data-dcl-scheme="dark"] button[aria-selected="true"] {
color: #11292f; background-color: #8fe1da;
}
.example-profile-form-rows[data-dcl-scheme="dark"] dialog { color: #eff8f9; background-color: #142f36; }
.example-profile-form-rows[data-dcl-scheme="dark"] [data-note] { color: #eff8f9; background-color: #1c3c44; }
.example-profile-form-rows[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }
.example-profile-form-rows, .example-profile-form-rows * { box-sizing: border-box; }
.example-profile-form-rows { font: 1rem/1.5 system-ui, sans-serif; padding: 1rem; border-radius: 0.75rem; overflow-wrap: anywhere; }
.example-profile-form-rows h2, .example-profile-form-rows h3 { line-height: 1.15; margin-block: 0 0.75rem; }
.example-profile-form-rows p { margin-block: 0.5rem; }
.example-profile-form-rows ul { margin-block: 0.5rem; padding-inline-start: 1.5rem; }
.example-profile-form-rows article, .example-profile-form-rows details, .example-profile-form-rows [data-note] { border: 1px solid; border-radius: 0.375rem; padding: 0.75rem; }
.example-profile-form-rows button, .example-profile-form-rows summary, .example-profile-form-rows input, .example-profile-form-rows select {
min-block-size: 44px; border: 1px solid; border-radius: 0.375rem; padding: 0.5rem 0.75rem; font: inherit;
}
.example-profile-form-rows button, .example-profile-form-rows summary { cursor: pointer; transition: background-color 140ms ease-out; }
.example-profile-form-rows button:disabled { cursor: not-allowed; text-decoration: line-through; }
.example-profile-form-rows input { display: block; inline-size: 100%; }
.example-profile-form-rows dialog { max-inline-size: min(32rem, 90vw); border-radius: 0.75rem; padding: 1rem; }
.example-profile-form-rows th, .example-profile-form-rows td { padding: 0.5rem; text-align: start; border-block-end: 1px solid; }
.example-profile-form-rows table { border-collapse: collapse; inline-size: 100%; }
.example-profile-form-rows caption { font-weight: bold; text-align: start; }
.example-profile-form-rows dt { font-weight: 600; }
.example-profile-form-rows dd { margin: 0 0 0.75rem; }
.example-profile-form-rows [hidden] { display: none !important; }
.example-profile-form-rows .parts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.example-profile-form-rows .parts > div { display: grid; grid-template-columns: 1fr 2fr; grid-column: 1 / -1; align-items: baseline; gap: 0.5rem; } .example-profile-form-rows input + p { grid-column: 2; }
@media (max-width: 30rem) {
.example-profile-form-rows[data-dcl-layout="rail"] .parts { grid-template-columns: minmax(0, 1fr); }
.example-profile-form-rows[data-dcl-layout="rail"] .parts > :is(p, ul, article) { grid-column: 1; grid-row: auto; }
.example-profile-form-rows[data-dcl-layout="rail"] .parts > :is(details, nav) { grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { .example-profile-form-rows * { transition: none !important; } }
</style>
When to use
Use inline labels for a narrow list of related settings.
Avoid
Do not use placeholders in place of labels or visible instructions.
Accessibility
Associate every visible label and supporting hint with its input.
Was this useful? Send feedback.