This section forms the normalization and ergonomics foundation of browserux.css. It covers base HTML elements, from spacing reset to print styles.
Removes all default browser margin and padding for a predictable starting point:
*,
*::before,
*::after {
margin: 0;
padding: 0;
}Applies border-box globally so that borders and paddings are included in calculated dimensions:
*,
::before,
::after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}Inheriting from html allows third-party libraries to define their own box model without conflict.
html {
font-family: var(--bux-typo-font-family);
font-size: 62.5%;
min-height: 100%;
overflow-y: scroll;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-webkit-tap-highlight-color: transparent;
tab-size: 4;
-moz-tab-size: 4;
text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
scrollbar-gutter: stable;
}| Property | Role |
|---|---|
font-size: 62.5% |
Sets 1rem = 10px for easier calculations (1.6rem = 16px) |
min-height: 100% |
Flex/grid layouts with 100vh without blank page effect |
overflow-y: scroll |
Fallback: keeps scrollbar visible, prevents layout shifts |
scrollbar-gutter: stable |
Modern solution: reserves scrollbar space without forcing it visible |
-webkit-tap-highlight-color: transparent |
Removes the grey/blue flash on tap in Android/iOS |
text-size-adjust: 100% |
Prevents Safari iOS from changing text size on rotation |
tab-size: 4 |
Readable indentation in pre / code blocks |
overflow-y: scrollandscrollbar-gutter: stableboth solve the same problem (layout shift caused by the scrollbar) but for different browsers. Both rules are kept for full coverage.
overscroll-behavior is no longer applied globally on html. While useful for preventing scroll chaining in specific UI patterns, applying it at the page level also changes native browser behaviors such as pull-to-refresh or gesture navigation in some environments. It is better used deliberately on scrollable components like dialogs, drawers, and side panels.
body {
background: var(--bux-page-bg);
color: var(--bux-page-color);
font-size: var(--bux-typo-font-size);
line-height: var(--bux-typo-line-height);
min-height: 100%;
overflow-wrap: break-word;
}backgroundandcolorapply the theme on load (with automatic dark mode support).min-height: 100%: ensures compatibility with sticky footer layouts.overflow-wrap: break-word: prevents long words or URLs from overflowing their container.
h1, h2, h3, h4, h5, h6 {
text-wrap: balance;
}text-wrap: balance distributes heading text more evenly across multiple lines, preventing unsightly orphans. Particularly effective on narrow viewports.
Replaces the native 3D border with a clean separator that adapts to the current theme:
hr {
border: none;
border-top: 1px solid currentColor;
color: inherit;
height: 0;
overflow: visible;
}Prevents block quotes and code blocks from exceeding their container:
blockquote,
pre {
max-width: 100%;
}Applies a consistent monospace font for pre blocks:
pre {
font-family: var(--bux-typo-font-family-mono);
}a {
outline: 0;
text-decoration: none;
text-decoration-skip-ink: auto;
text-underline-offset: 0.2em;
touch-action: manipulation;
}text-decoration: none: removes underline (reapply in your styles if needed).text-underline-offset: 0.2em: offsets the underline to avoid collisions with descenders.touch-action: manipulation: removes the 300ms tap delay on mobile.
abbr[title],
dfn[title] {
cursor: help;
text-decoration: underline dotted;
}b,
strong {
font-weight: bolder;
}code,
kbd,
samp {
font-family: var(--bux-typo-font-family-mono);
}
code {
max-width: 100%;
white-space: pre-wrap;
}small {
font-size: 80%;
}sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub { bottom: -0.25em; }
sup { top: -0.5em; }Removes the space below inline media caused by default baseline alignment:
audio,
canvas,
iframe,
img,
svg,
video {
vertical-align: middle;
}img,
svg,
video {
height: auto;
max-width: 100%;
}img::selection {
background-color: var(--bux-transparent);
}svg {
fill: currentColor;
}SVGs automatically inherit the current text color, simplifying theming (dark mode included).
area {
touch-action: manipulation;
}table {
border-color: inherit;
text-indent: 0;
}border-color: inherit: fixes border color inheritance in Chrome and Safari.text-indent: 0: removes automatic indentation in some WebKit versions.
table,
td {
max-width: 100%;
}fieldset {
border: none;
padding: 0;
}
legend {
padding: 0;
}button {
appearance: none;
border: none;
background: none;
user-select: none;
}button,
input,
label,
select,
textarea {
touch-action: manipulation;
}button,
input,
optgroup,
select,
textarea {
font-family: inherit;
font-size: 100%;
}button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled),
label[for],
select {
cursor: pointer;
}
[disabled],
[aria-disabled="true"] {
cursor: not-allowed;
}button,
[type="button"],
[type="reset"],
[type="submit"] {
appearance: button;
-webkit-appearance: button;
}input,
textarea {
max-width: 100%;
}input,
select,
textarea {
user-select: text;
}[type="search"] {
appearance: textfield;
-webkit-appearance: textfield;
outline-offset: -2px;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}textarea {
field-sizing: content;
resize: vertical;
}field-sizing: content automatically adjusts the textarea height to its content, without JavaScript. resize: vertical is kept as a fallback.
Requires Chrome 123+, Edge 123+. Firefox and Safari do not yet support
field-sizing.
::-moz-focus-inner {
border-style: none;
padding: 0;
}
:-moz-ui-invalid {
box-shadow: none;
}summary {
display: list-item;
}[role="button"],
details[open] summary,
summary {
user-select: none;
}[hidden] element
[hidden]:where(:not([hidden="until-found"])) {
display: none !important;
}The !important is intentional: it guarantees that the semantic meaning of the hidden state always overrides potential specificity conflicts.
The :where(:not([hidden="until-found"])) part is equally intentional:
- Classic
hiddenmust stay truly hidden, even if another stylesheet setsdisplay: block,flex, orgrid. hidden="until-found"must keep its native browser behavior so content can still be revealed by "Find in page" or fragment navigation.
This keeps the defensive reset while preserving a modern HTML capability that would otherwise be broken by a blanket [hidden] { display: none !important; } rule.
Removes backgrounds, shadows, and decorative colors for clean print output, and displays link URLs:
@media print {
*,
*::before,
*::after {
background: transparent !important;
box-shadow: none !important;
color: #000 !important;
text-shadow: none !important;
}
a[href]::after {
content: " (" attr(href) ")";
}
img,
figure {
page-break-inside: avoid;
}
}