Home >Web Front-end >CSS Tutorial >How Do I Replace Deprecated Table Attributes in HTML5?

How Do I Replace Deprecated Table Attributes in HTML5?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-31 12:27:49667browse

How Do I Replace Deprecated Table Attributes in HTML5?

HTML5 Table Attribute Replacements

In HTML5, several table attributes commonly used in HTML4 and earlier have been deprecated. Instead, CSS properties are now utilized to control the appearance and layout of tables.

Specifically, the following HTML4 table attributes are no longer valid in HTML5:

  • cellpadding
  • cellspacing
  • valign
  • align

CSS Replacements

The following CSS properties replace the deprecated HTML4 attributes:

  • cellpadding: padding

    • Example: th, td { padding: 5px; }
  • cellspacing: border-collapse and border-spacing

    • border-collapse: separate; border-spacing: 5px; (cellspacing="5")
    • border-collapse: collapse; border-spacing: 0; (cellspacing="0")
  • valign: vertical-align

    • Example: th, td { vertical-align: top; }
  • align (center): margin applied to the table element

    • Example: table { margin: 0 auto; }

The above is the detailed content of How Do I Replace Deprecated Table Attributes in HTML5?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn