HTML/CSS:如何将指向其他网站的链接与网页中心对齐-->;尝试在CSS中将链接对齐到中心。。。不起作用

HTML/CSS:如何将指向其他网站的链接与网页中心对齐-->;尝试在CSS中将链接对齐到中心。。。不起作用,html,css,hyperlink,alignment,center,Html,Css,Hyperlink,Alignment,Center,我有以下带有body标记的HTML代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Dwight Schrute's Bidding Blunder</title> <!-- the MAIN.CSS file is linked here --> <link rel="

我有以下带有body标记的HTML代码:

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <title>Dwight Schrute's Bidding Blunder</title>

    <!-- the MAIN.CSS file is linked here -->
    <link rel="stylesheet" href="guessing-game.css">


  </head>

  <body>

    <body class='bg' background="dwight_schrute.jpg"></body>


    <h1 align="center">Dwight Schrute's Bidding Blunder</h1>

    <div class="youTubeLink">
      <a href="https://www.youtube.com/watch?v=Vhsng72lC4s">The Office Episode: Bidding Blunder</a>
    </div> 

    <div>
      <p id="p1">BEFORE I GUESS</p>
      <p id="p2">ANYTHING</p>
      <p id="p3">I ASK MYSELF</p>
      <p id="p4">"WOULD AN IDIOT DO THAT?"</p>
      <p id="p5">AND IF THE ANSWER IS YES</p>
      <p id="p6">I DO NOT GUESS THAT</p>
      <br>
      <p id="p7">-Dwight Schrute</p>
    </div>

 </body>

</html>   
但我的链接仍然是左对齐的(链接位于页面左上方并带下划线):


您正在将文本对齐属性指定给一个链接元素,该元素是一个内联元素,因此其宽度仅为其内容的大小。如果将链接放置在div元素内,并将“文本对齐”属性指定给该div,则由于div是块级元素,它将占据页面宽度的100%,链接将与页面中心对齐:

正文{
背景颜色:浅蓝色;
}
youTubeLink先生{
文本对齐:居中;
}
.youTubeLink>a{
颜色:白烟;
}


您将
文本对齐:居中.bg {
    background-size:100% 100%;
}

.youTubeLink {
    text-align: center;
}

.youTubeLink>a {
    color: whitesmoke;
}


a:visited {
    text-align: center;
    /* color: #3C1900; */
    color: whitesmoke;
}