Sobes.tech
Junior

What is CSS Reset?

sobes.tech AI

Answer from AI

CSS Reset is a set of CSS rules that nullify or establish uniform base styles for most HTML elements across different browsers. It helps prevent default display inconsistencies that can arise from built-in browser styles.

Main issues addressed by CSS Reset:

  • Margins (margin, padding): Resetting default margins of elements like <h1>, p, ul, li.
  • Font sizes: Setting a uniform base font size or resetting default sizes for headings.
  • List styles: Removing markers from lists (ul, ol) and resetting their margins.
  • Underlines: Removing underlines from links (a).
  • Image sizes: Preventing images from overflowing their container boundaries.

Examples of popular CSS Resets:

  • Eric Meyer's Reset CSS: One of the older and widely used resets.
  • Normalize.css: Instead of a full reset, it makes styles more consistent while preserving useful default styles.

Basic CSS Reset example:

/* CSS Reset */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}

Using CSS Reset is a good practice to ensure predictable and consistent rendering of web pages across different browsers before applying custom styles.