You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HTML样式在WordPress失效:<h1>未应用font-family问题求助

WordPress中body字体样式未应用到h1标签的问题

我是HTML新手,在W3Schools空间使用指定代码练习时,<style>标签内的样式能正常让整个body按预期生效,但将包含该样式的完整代码复制到WordPress代码编辑器后,font-family: Arial, sans-serif;样式并未应用到<h1>Heading 1</h1>和<h1>This is a heading</h1>标签上。

我在两个平台使用完全相同的代码,但结果不一致,WordPress对代码的解析方式是否和W3Schools不同?

最初我以为是行内样式覆盖了全局样式,将<h1 style="font-size:60px;">Heading 1</h1>修改为<h1>Heading 1</h1>,但修改后两个平台的结果仍不一致。

完整代码

<!DOCTYPE html>
<html lang="en">
    <head>
        <style>
            body {
                font-family: Arial, sans-serif;
                background-color: powderblue;
            }
        </style>
        <title>A Title</title>
    </head>
    <body>
        <h1 style="font-size:60px;">Heading 1</h1>
        <h1>This is a heading</h1>
        <hr>
        <p>My first paragraph</p>
        <p title="I'm a tooltip">This is a paragraph.</p>
        <p>This is<br>a paragraph<br>with line breaks.</p>
    </body>
</html>

结果对比

  • W3Schools空间运行结果:body的Arial字体样式正常应用到所有h1标签,页面背景色为powderblue
  • WordPress编辑器运行结果:h1标签未应用Arial字体样式,仅页面背景色生效

内容的提问来源于stack exchange,提问作者Alberto

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 19:06:05