Why is the
tag deprecated in HTML?

前端 未结 12 1647
攒了一身酷
攒了一身酷 2020-11-22 01:36

I am just curious as to why the

tag in HTML was deprecated.

The

was a simple way of quickly center-aligning b
相关标签:
12条回答
  • 2020-11-22 02:25

    CSS has a text-align: center property, and since this is purely a visual thing, not semantic, it should be relegated to CSS, not HTML.

    0 讨论(0)
  • 2020-11-22 02:28

    According to W3Schools.com,

    The center element was deprecated in HTML 4.01, and is not supported in XHTML 1.0 Strict DTD.

    The HTML 4.01 spec gives this reason for deprecating the tag:

    The CENTER element is exactly equivalent to specifying the DIV element with the align attribute set to "center".

    0 讨论(0)
  • 2020-11-22 02:28

    Food for thought: what would a text-to-speech synthesizer do with <center>?

    0 讨论(0)
  • 2020-11-22 02:29

    You can add this to your css and use <div class="center"></div>

    .center{
      text-align: center;
      margin: auto;
      justify-content: center;
      display: flex;
    }
    

    or if you want to keep <center></center> and be prepared in case its ever removed, add this to your css

    center{
      text-align: center;
      margin: auto;
      justify-content: center;
      display: flex;
    }
    
    0 讨论(0)
  • 2020-11-22 02:35

    HTML is intended for structuring data, not controlling layout. CSS is intended to control layout. You'll also find that many designers frown on using <table> for layouts for this very same reason.

    0 讨论(0)
  • 2020-11-22 02:38

    The <center> element was deprecated because it defines the presentation of its contents — it does not describe its contents.

    One method of centering is to set the margin-left and margin-right properties of the element to auto, and then set the parent element’s text-align property to center. This guarantees that the element will be centered in all modern browsers.

    0 讨论(0)
提交回复
热议问题