After adding absolute, the text-align, width, and so on of the row-level element span will take effect. Why?

such as title:

after position:absolute is added, the text-align, width, and height of the row-level element span take effect. Why?

Code:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    body {
      margin: 0;
    }
    .box {
      margin: 15% auto;
      width: 200px;
      height: 200px;
      box-sizing: border-box;
      border: 1px solid darkblue;
    }
    .text {
      /* position display: block; */
      position: absolute;
      width: 200px;
      height: 200px;
      text-align: center;
      line-height: 200px;
    }
  </style>
</head>
<body>
  <div class="box">
    <span class="text">letter</span>
  </div>
</body>
</html>
Apr.04,2021
After

position:absolute, span is display:block;


plus position:absolute , the element is treated as a block element

by default.
Menu