Skip to content

搞英语 → 看世界

翻译英文优质信息和名人推特

Menu
  • 首页
  • 作者列表
  • 独立博客
  • 专业媒体
  • 名人推特
  • 邮件列表
  • 关于本站
Menu

h1 元素的默认样式正在更改

Posted on 2025-04-11

h1 元素的默认样式正在更改

哇,这种情况很少见! Firefox 正在推出对嵌套<h1>元素的默认用户代理样式表的更改,目前用户数量从 5% 增加到 50%,并计划于 2025 年 6 月在 Firefox 140 上全面推出。Chrome 正在显示弃用警告,Safari 预计将来也会效仿。

有什么变化?嵌套在<article> 、 <aside> 、 <nav>和<section>内的<h1>元素的默认大小。

这些是被删除的默认样式:

 /* 其中 x 是:is(文章, 旁白, 导航, 部分) */ x h1 {边距块: 0.83 em ;字体大小: 1.50em ; } x x h1 {边距块: 1.00 em ;字体大小: 1.17 em ; } x x x h1 {边距块: 1.33 em ;字体大小: 1.00em ; } x x x x h1 {边距块: 1.67 em ;字体大小: 0.83 em ; } x x x x x h1 {边距块: 2.33 em ;字体大小: 0.67 em ; }

简而言之,多年前,HTML 规范引入了这样的想法:嵌套部分中的<h1>应该与<h2>具有相同的含义(以及视觉样式)。这从未真正流行起来,也没有被可访问性树反映出来,并于 2022 年从 HTML 规范中删除。浏览器现在正在尝试清理旧的默认样式。

那篇文章中的建议对我来说听起来很明智:

  • 不要依赖默认的浏览器样式来传达标题层次结构。使用<h2>明确定义文档层次结构,使用 <h2> 作为二级标题,使用<h3>作为第三级标题,等等。
  • 始终为<h1>元素定义自己的font-size和margin 。

通过黑客新闻

标签: css 、 html 、 firefox 、 mozilla 、浏览器、 safari 、 chrome 、网络标准

原文: https://simonwillison.net/2025/Apr/11/default-styles-for-h1/#atom-everything

本站文章系自动翻译,站长会周期检查,如果有不当内容,请点此留言,非常感谢。
  • Abhinav
  • Abigail Pain
  • Adam Fortuna
  • Alberto Gallego
  • Alex Wlchan
  • Answer.AI
  • Arne Bahlo
  • Ben Carlson
  • Ben Kuhn
  • Bert Hubert
  • Bits about Money
  • Brian Krebs
  • ByteByteGo
  • Chip Huyen
  • Chips and Cheese
  • Christopher Butler
  • Colin Percival
  • Cool Infographics
  • Dan Sinker
  • David Walsh
  • Dmitry Dolzhenko
  • Dustin Curtis
  • eighty twenty
  • Elad Gil
  • Ellie Huxtable
  • Ethan Dalool
  • Ethan Marcotte
  • Exponential View
  • FAIL Blog
  • Founder Weekly
  • Geoffrey Huntley
  • Geoffrey Litt
  • Greg Mankiw
  • Henrique Dias
  • Hypercritical
  • IEEE Spectrum
  • Investment Talk
  • Jaz
  • Jeff Geerling
  • Jonas Hietala
  • Josh Comeau
  • Lenny Rachitsky
  • Liz Danzico
  • Lou Plummer
  • Luke Wroblewski
  • Matt Baer
  • Matt Stoller
  • Matthias Endler
  • Mert Bulan
  • Mostly metrics
  • News Letter
  • NextDraft
  • Non_Interactive
  • Not Boring
  • One Useful Thing
  • Phil Eaton
  • Product Market Fit
  • Readwise
  • ReedyBear
  • Robert Heaton
  • Rohit Patel
  • Ruben Schade
  • Sage Economics
  • Sam Altman
  • Sam Rose
  • selfh.st
  • Shtetl-Optimized
  • Simon schreibt
  • Slashdot
  • Small Good Things
  • Steve Blank
  • Taylor Troesh
  • Telegram Blog
  • The Macro Compass
  • The Pomp Letter
  • thesephist
  • Thinking Deep & Wide
  • Tim Kellogg
  • Understanding AI
  • Wes Kao
  • 英文媒体
  • 英文推特
  • 英文独立博客
©2025 搞英语 → 看世界 | Design: Newspaperly WordPress Theme