Skip to content
Tutorials Center
My learning

Topics

Lesson 11 of 58 ยท Content

Reboot: Bootstrap's Built-in CSS Reset

Learn what Bootstrap 5 Reboot changes in plain HTML: box-sizing, the native font stack, margins, lists, code, tables, forms, buttons and the hidden attribute.

Before you add a single Bootstrap class, the stylesheet has already changed how plain HTML looks. A bare <h1>, <p>, <ul> or <button> is not displayed with the browser's defaults any more. That first layer is called Reboot. It is Bootstrap's opinionated reset: it removes the differences between browsers and sets a small, consistent base that the components and utilities build on.

Knowing what Reboot does saves you hours of confusion. It explains why headings have no top margin, why lists lose their "browser" spacing, why your fonts look like the operating system's own, and why <button> elements behave the same everywhere. This lesson walks through the rules by element group, so you can predict what the page will look like and override the right thing when you need to.

What Reboot is, and what it is not

Reboot is not a separate file. It is the first part of bootstrap.css, written as element selectors (h1, p, table, button) and a few attribute selectors. It is built on top of Normalize, a well-known reset idea, but it goes further and makes choices: it picks one spacing direction, one font stack and one box model.

It differs from a classic "reset everything to zero" file in one way: it does not remove all styling. Bold stays bold, lists keep their bullets, and headings stay larger than text. Reboot only changes things that are inconsistent or hard to work with.

Reboot is styled with element selectors, which have low specificity. That is deliberate. Any class you add (a Bootstrap utility or one of your own) beats Reboot without a fight. For a refresher on how that works, see specificity in CSS.

flowchart TB
  A["Browser defaults"] --> B["Reboot<br/>element rules"]
  B --> C["Content styles<br/>.table, .img-fluid, .lead"]
  C --> D["Components and utilities<br/>.btn, .card, .mt-3"]
  D --> E["Your own CSS"]

Each layer can override the one above it. Your own CSS comes last, so it always has the final word.

Page defaults

Reboot starts with a few rules that affect every element:

  • box-sizing: border-box is set on every element and pseudo-element. Padding and border are included in width, so a width: 100% box with padding does not overflow. See the box model for why this matters.
  • The <body> margin is removed (margin: 0), and the body gets the base font size (1rem), line height (1.5), text color and background color. In Bootstrap 5.3 these come from CSS variables such as --bs-body-font-size and --bs-body-color, which is what makes dark mode possible.
  • The root font size stays at the browser's value (usually 16 px). Bootstrap uses rem units, so if a visitor changes the browser's default font size, your layout scales with it.
  • Smooth scrolling is enabled on :root for users who have not asked for reduced motion.
  • A tap highlight is removed on touch devices (-webkit-tap-highlight-color), so tapping a link does not flash a gray box.

The native font stack

Bootstrap does not download a web font. The base font is a native font stack: a list of fonts that already exist on the user's device, so the page text uses the same typeface as the operating system's own interface.

CSS
--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto,
  "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif,
  "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas,
  "Liberation Mono", "Courier New", monospace;

The benefits are speed (no font request, no flash of invisible text), a familiar look (San Francisco on Apple devices, Segoe UI on Windows, Roboto on Android) and good support for many writing systems. The trade-off is that your page looks slightly different on each platform. If you need one specific brand font, load it and override the variable. The lesson on customizing with CSS variables shows how, and web fonts in CSS covers loading them.

Headings, paragraphs and lists

Reboot uses margin in one direction. Most block elements get margin-top: 0 and a bottom margin (1rem for paragraphs, .5rem for headings). Because spacing only goes down, vertical margins never need to collapse, and your layout is easier to predict. When you stack elements, the gap between them is exactly the bottom margin of the upper one.

Element What Reboot sets
h1 to h6 margin-top: 0, margin-bottom: .5rem, weight 500, line height 1.2. Sizes scale with the viewport for h1 to h4
p margin-top: 0, margin-bottom: 1rem
ul, ol padding-left: 2rem, margin-top: 0, margin-bottom: 1rem
Nested lists margin-bottom: 0, so a list inside a list adds no extra gap
dl, dt, dd dt is bold, dd has margin-left: 0 and margin-bottom: .5rem
blockquote margin: 0 0 1rem, with no side indentation
figure margin: 0 0 1rem, with the browser's side indent removed
hr margin: 1rem 0, a thin line with a color from a variable

Notice that h1 to h6 get their appearance from element rules, but the same sizes are available as classes (.h1 to .h6) when a paragraph should look like a heading. The typography lesson covers those classes, display headings and lead text.

Inline text, abbreviations and addresses

A few inline elements are adjusted:

  • b and strong use font-weight: bolder, which is relative to the parent, so bold text inside a heading stays proportionate.
  • small is set to .875em and mark gets padding and a highlight color from variables.
  • sub and sup have line-height: 0, so they do not push the line taller.
  • abbr[title] gets a dotted underline and a help cursor, so people notice the tooltip text.
  • address loses its italics: font-style: normal, with a bottom margin. Use it for contact information, and style it as you like.
  • Links are colored and underlined by default. A link with no href and no class (<a> used as a placeholder) is shown as plain text with no color or underline.

Code and user input

Code uses the monospace stack. The elements differ in how they look:

  • code is shown in a pink-ish color (--bs-code-color) for inline snippets, at .875em.
  • pre is a block with overflow: auto, so long lines scroll instead of breaking the layout. A code inside pre inherits color and size, so blocks stay clean.
  • kbd shows keyboard input as a small dark chip with light text and rounded corners. Nest kbd elements to show key combinations; the inner ones lose their padding so a combination looks like one unit.
  • samp is for program output and uses the same monospace font.

Tables, forms and buttons

Reboot makes tables and form controls predictable:

  • Tables get border-collapse: collapse, and the <caption> is placed below the table (caption-side: bottom) with muted text. Header cells inherit the text alignment of the table, not the browser default of centered. The nicer look (stripes, borders, hover) comes from the .table classes.
  • label is inline-block, which allows margins on it.
  • Form controls (input, button, select, textarea, optgroup) get margin: 0 and inherit the font family, size and line height from the page. In plain browsers, buttons and inputs often use a different, smaller font; Reboot removes that mismatch.
  • textarea can only be resized vertically (resize: vertical), which stops users from dragging it wider than the layout.
  • fieldset has no border or padding, and legend is block-level, full width and sized like a small heading.
  • button uses cursor: pointer only when it is not disabled. Any element with role="button" also gets the pointer cursor, which helps when you build a button from a <div> or <a> (prefer real buttons whenever you can; see accessibility).
  • select:disabled keeps full opacity, so disabled drop-downs remain readable.

Miscellaneous elements

The rest of the small fixes:

  • summary gets a pointer cursor, because it toggles a <details> element when clicked.
  • iframe has no border.
  • output is inline-block.
  • progress is aligned to the text baseline.
  • img and svg use vertical-align: middle, which removes the small gap that otherwise appears below an inline image (the baseline gap). The images lesson shows how .img-fluid builds on this.
  • [hidden] is set with display: none !important. In plain HTML, an author rule such as display: flex can accidentally show an element that has the hidden attribute. With the !important in Reboot, the attribute always wins. For responsive hiding, use the d-none classes instead.

Try it: elements in Reboot

The editor below loads Bootstrap and shows plain HTML elements without a single class. Toggle the stylesheet to compare Bootstrap's defaults with the browser's own. (The toggle disables the whole stylesheet, but with no classes in the markup, the only changes you see are Reboot's.)

Plain HTML with Reboot on and off

With Bootstrap on, notice the sans-serif system font, the inverted kbd chip, the upright address and the lack of indentation on the quote. With it off, the browser's serif font, italic address and indented quote return.

Try it: the [hidden] rule

A class like d-flex sets display: flex !important, and it would beat the hidden attribute. Plain CSS shows the problem Reboot solves for the unclassed case.

Why [hidden] needs a safety net

Overriding Reboot

You rarely need to fight Reboot, because its selectors are weak. A few safe ways to change it:

  1. Add a class. Any class beats an element selector: <p class="mb-0"> removes the paragraph margin.
  2. Set a CSS variable. Many of Reboot's values come from --bs-* variables on :root, so :root { --bs-body-font-size: 1.125rem; } changes the whole page. See CSS variables.
  3. Override a Sass variable when you build from source: $font-family-sans-serif, $body-bg, $headings-margin-bottom. See Sass customization.
  4. Write your own element rule after Bootstrap. With equal specificity, the later rule wins, so load your stylesheet after Bootstrap's.

If you use Bootstrap in a project that already has its own reset (Normalize, a Tailwind preflight, a global * { margin: 0 }), pick one reset. Two resets fight each other and produce surprises, especially around forms and headings. The resets lesson explains the options.

Common mistakes

  • Expecting a heading to have top margin. Reboot removes it. Add mt-4 when you need space above a section title.
  • Using <a> as a button without role="button". The cursor will not change and screen readers will announce a link.
  • Overriding box-sizing for the whole page. Components assume border-box. Change it on single elements only.
  • Mixing in a second CSS reset. See the tip above.
  • Styling links by tag when Bootstrap's link utilities would do. Classes such as link-primary are easier to maintain.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why does Reboot give most block elements a bottom margin but no top margin?

    Margins in one direction mean the gap between two blocks is exactly the bottom margin of the upper one, with no margin collapsing to reason about.
  2. 2. What is the Bootstrap 5 'native font stack'?

    The stack starts with system-ui and lists platform fonts such as Segoe UI and Roboto, so no font file is downloaded and text looks native on every system.
  3. 3. A <div class="d-flex" hidden> is still visible in your page. What is the most likely reason?

    Reboot uses [hidden] { display: none !important }, but the d-flex utility is also !important, has the same specificity and is defined later, so it wins. Use d-none or remove the d-flex class instead.
  4. 4. Which is the safest way to change the base font size of a Bootstrap 5.3 page?

    Reboot reads its values from variables, so overriding the variable (or the Sass variable at build time) changes everything consistently without touching vendor files.

Summary

  • Reboot is the element-level reset at the start of bootstrap.css. It makes plain HTML look the same in every browser.
  • It sets box-sizing: border-box, removes the body margin and uses a native system font stack with a monospace stack for code.
  • Spacing goes in one direction (bottom margins), for headings, paragraphs, lists, quotes and figures.
  • Code, kbd, tables, forms, buttons, summary, images and the hidden attribute all get small fixes.
  • Reboot uses weak element selectors, so classes, variables and your own later CSS override it easily.
  • Do not stack a second reset on top of it.

Next: Bootstrap tables.