• Skip to main content
  • Skip to search
  • Skip to select language
MDN Web Docs
  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Extensions

      Developing extensions for web browsers

    • Accessibility

      Build web projects usable for all

    • Web Technology

      Web technology reference for developers

  • Learn
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • Plus
    • Overview

      A customized MDN experience

    • AI Help

      Get real-time assistance and support

    • Updates

      All browser compatibility updates at a glance

    • Documentation

      Learn how to use MDN Plus

    • FAQ

      Frequently asked questions about MDN Plus

  • Curriculum New
  • Blog
    • Playground

      Write, test and share your code

    • HTTP Observatory

      Scan a website for free

    • AI Help

      Get real-time assistance and support

  • Log in
  • Sign up for free
  1. 面向开发者的 Web 技术
  2. HTML(超文本标记语言)
  3. HTML 参考
  4. HTML 元素参考
    • English (US)
    • Deutsch
    • Español
    • Français
    • 日本語
    • 한국어
    • Português (do Brasil)
    • 正體中文 (繁體)

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

在本文中

  • DOM 接口
  • 示例 1
  • 示例 2(CSS 替代方案)
  • 示例 3(CSS 替代方案)
  • 规范
  • 浏览器兼容性
  • 参见
  1. HTML(超文本标记语言)
  2. 指南
  3. 内容分类
  4. 注释
  5. HTML 中使用的日期与时间格式
  6. 约束验证
  7. viewport meta 标记
  8. 响应式图片
  9. 微数据
  10. 微格式
  11. 怪异模式和标准模式
  12. HTML cheatsheet
  13. How to
  14. Define terms with HTML
  15. 使用数据属性
  16. 允许图片和 canvas 跨源使用
  17. 在图像上层添加点击映射
  18. 编写快速加载的 HTML 页面
  19. Add JavaScript
  20. 参考
  21. HTML 元素
    1. 已弃用
    2. 已弃用

    3. 已弃用
    4. 已弃用
    5. 实验性
    6. 已弃用
    7. 已弃用
    8. 已弃用

示例 2(CSS 替代方案)

html
这段文字将居中。

本段也是如此。

结果

示例 3(CSS 替代方案)

html

这段文字将居中。
这一行也是如此。

结果

备注: 将 text-align:center 应用于

或

元素会将这些元素的内容居中,同时保持其总体尺寸不变。

规范

Specification
HTML
# center

浏览器兼容性

参见

  • text-align
  • display

Help improve MDN

Learn how to contribute.

This page was last modified on 2025年4月13日 by MDN contributors.

View this page on GitHub • Report a problem with this content
MDN logo

Your blueprint for a better internet.

  • MDN on Bluesky
  • MDN on Mastodon
  • MDN on X (formerly Twitter)
  • MDN on GitHub
  • MDN Blog RSS Feed

MDN

  • About
  • Blog
  • Careers
  • Advertise with us

Support

  • Product help
  • Report an issue

Our communities

  • MDN Community
  • MDN Forum
  • MDN Chat

Developers

  • Web Technologies
  • Learn Web Development
  • MDN Plus
  • Hacks Blog
  • Website Privacy Notice
  • Cookies
  • Legal
  • Community Participation Guidelines

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2025 by individual mozilla.org contributors. Content available under a Creative Commons license.