所有元素和伪元素设置box-sizing为border-box * *::after *::befor { box-sizing: border-box; } 防止字体膨胀 当网站从纵向切换为横向时, Mobile Safari 会增加默认字体的大小,也就是说在手机上会产生变化。 html { -moz-text-size-adjust: none; -webkit-text-size-adjust: none; text-size-adjust: none; } 删除元素的默认边距 body, h1, h2, h3, h4,p, figure, blockquote, dl, dd { margin: 0; } 删除ul、ol 的默认样式 ul["role-list"] ol["role-list"] { list-style: none; } 设置默认body样式 body { min-height: 100vh; line-height: 1.1; } 在标题和交互元素上设置较短的行高 h1, h2, h3, h4, button, input, label{ line-height: 1.1; } 设置标题元素换行和排版 text-wrap: balance; 可以让每一行文字的个数尽可能的相等,即使宽度足够的大。特别适合居中排版的文字展示,例如官网首页 slogan。 5分钟快速了解text-wrap:balance的作用 « 张鑫旭-鑫空间-鑫生活 h1, h2, h3, h4 { text-wrap: balance; } 给没有 class的元素设置默认样式 a:not([class]) { text-decoration-skip-ink: auto; color: currentColor; } 继承输入和按钮的字体 input, button, textarea, select { font: inherit; } 确保没有 rows属性的文本区域不会很小 textarea:not([rows]) { min-height: 10em; } 任何已锚定的内容都应该有额外的滚动边距 :target { scroll-margin-block: 5px; } 完整重置代码 /* Box sizing rules */ *, *::before, *::after { box-sizing: border-box; } /* Prevent font size inflation */ html { -moz-text-size-adjust: none; -webkit-text-size-adjust: none; text-size-adjust: none; } /* Remove default margin in favour of better control in authored CSS */ body, h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; } /* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */ ul[role='list'], ol[role='list'] { list-style: none; } /* Set core body defaults */ body { min-height: 100vh; line-height: 1.5; } /* Set shorter line heights on headings and interactive elements */ h1, h2, h3, h4, button, input, label { line-height: 1.1; } /* Balance text wrapping on headings */ h1, h2, h3, h4 { text-wrap: balance; } /* A elements that don't have a class get default styles */ a:not([class]) { text-decoration-skip-ink: auto; color: currentColor; } /* Make images easier to work with */ img, picture { max-width: 100%; display: block; } /* Inherit fonts for inputs and buttons */ input, button, textarea, select { font: inherit; } /* Make sure textareas without a rows attribute are not tiny */ textarea:not([rows]) { min-height: 10em; } /* Anything that has been anchored to should have extra scroll margin */ :target { scroll-margin-block: 5ex; } 来源:A (more) Modern CSS Reset - Andy Bell 其他CSS重置 normalize.css sanitize.css reboot.scss destyle.css: Opinionated reset stylesheet that provides a clean slate for styling your html. 参考文章 Modern CSS Reset / Global Styles