首页 > 文章列表 > 我们如何根据HTML中的周围元素设置对齐方式?

我们如何根据HTML中的周围元素设置对齐方式?

318 2023-09-17

使用align属性来设置对齐方式。您可以尝试运行以下代码来实现 HTML 中的align 属性 -

注意 - HTML5 中不推荐使用align 属性。请改用 CSS。

示例

<!DOCTYPE html>
<html>
   <body>
      <p align="right">A right-aligned paragraph.</p>
      <p><b>Note:</b> The align attribute is not supported in HTML5. Use CSS instead.</p>
   </body>
</html>