CSS檔案中如何使用align屬性?

來源:互聯網
上載者:User
我在一個html頁面中引入一個demo.css,其他都很正常,到但是h4標籤的align屬性,不能正確顯示。是因為在連結式中不能寫align嗎?寫成行內式就沒有問題。
代碼如下:
這是html頁面的幾句代碼

 <h1 style="color:blue">前端工程師:JavaScript,PHP,CSS!<br/> </h1> <h2>2.測試CSS的四種形式</h2> <hr/> <h3>3.css的匯入式</h3> <br/> <h4>4.這是CSS的連結式</h4>這是CSS檔案:    h3{    color: green;}h4{    color: pink;    align:center;}.my{     align:right; color: blue;}#xzq{    align:left;color: red;}.php{color: red;}

再來個


再來個:


麻煩幫我看看??我也是新手

應該是 text-align:center; 但是align是不行的

<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title></title>    <style media="screen">      *{        padding: 0;        margin: 0;      }      h4{        background-color: rgb(222, 93, 174);        color: rgb(194, 238, 7);        text-align: center;      }    </style>  </head>  <body>    <h4>這是CSS連結式</h4>  </body></html>

但是這麼寫要注意,所有的<h4></h4>都加上了這個屬性,最好給這個填一個id或者class,單獨修改這個h4標籤下文字的對齊。


text-align ,應該是你在找的 屬性

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.