<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      對于HTML標簽style屬性的使用方法詳細說明(附具體案例)

      [摘要]本篇文章為大家講解的是關于HTML標簽的style屬性的定義和作用,還有關于HTML中的style屬性的使用方法實例,還有關于HTML標簽中的style屬性的各種樣式解析。讓我們一起來看本篇文章吧首先我們介紹下HTML標簽style屬性的定義吧:style 屬性是規定元素的行內樣式(inline ...
      本篇文章為大家講解的是關于HTML標簽的style屬性的定義和作用,還有關于HTML中的style屬性的使用方法實例,還有關于HTML標簽中的style屬性的各種樣式解析。讓我們一起來看本篇文章吧

      首先我們介紹下HTML標簽style屬性的定義吧:

      style 屬性是規定元素的行內樣式(inline style)

      style 屬性將覆蓋任何全局的樣式設定,例如在 <style> 標簽或在外部樣式表中規定的樣式。

      HTML style 屬性實例

      在 HTML 文檔中使用 style 屬性:

      <h1 style="color:blue; text-align:center">This is a header</h1>
      <p style="color:red">This is a paragraph.</p>

      HTML標簽style屬性的語法:

      <element style="value">

      HTML標簽style屬性的屬性值:

      style_definition : 一個或多個由分號分隔的 CSS 屬性和值。

      HTML中的style屬性的各種樣式解析

      1.style屬性可以設置字體樣式(font-family:)、字體大小(font-size:)、文本的顏色(color:)等內容。它可以在

      每個不同的標簽中設置,也可以放置到CSS樣式表中進行設置。因為我的文章都是跟隨著http://www.codecademy.com來

      寫的,目前還沒有介紹到CSS,所以在這里暫時先不涉及CSS,僅僅是在標簽中進行設置,下面是示例代碼和示意圖:

      <!DOCTYPE html>
      <html>
      <head>
      <title>color the text</title>
      </head>
      <!-- now i will color the text-->
      <body>
      <h3 style="color:blue;font-size=20px">Hello World!</h3>
      <p style="color:red;font-size=10px">你好。。!</p>
      </body>
      </html>

      注意:

      a)我用的瀏覽器是chrome,在其中編輯并顯示時總是發現設置的10px字體沒有應用,通過查找chrome設置,發現

      是在chrome中設置的最小字體是12px,所以10px字體大小沒有用,把chrome瀏覽器的最小字體改小就好了。

      b)style屬性中的賦值方式是:屬性名稱:值,而不是習慣的等號=,如果用等號,則style效果不會被執行。

      2.style樣式中也可以設置背景顏色,style中包含屬性background-color,設置它的顏色值就可以使整個標簽范圍內的背景顏色變

      為background-color指定的顏色。下面是示例代碼和示意圖:

      <!DOCTYPE html>
      <html>
      <head>
      <title>color the text</title>
      </head>
      <!-- now i will color the text-->
      <body>
      <h3 style="color:blue;font-size=20px ;background-color:yellow">Hello World!</h3>
      <p style="color:red;font-size=10px ;background-color:green">你好!。!</p>
      </body>
      </html>

      3.文本對齊

      有些標簽屬性中有align屬性,可以設置文本對齊方式,在style中也可以設置類似的屬性。這個屬性值就是text-align。它的

      取值包括left、center和right。下面是示例代碼和示意圖:

      <!DOCTYPE html>
      <html>
      <head>
      <title>color the text</title>
      </head>
      <!-- now i will color the text-->
      <body>
      <h3 style="color:blue;font-size=20px ;background-color:yellow;text-align:center">Hello World!</h3>
      <p style="color:red;font-size=10px ;background-color:green;text-align:right">你好。。!</p>
      </body>
      </html>

      關于html的style屬性的兩種具體用法實例:

      <!DOCTYPE html>
      <html>
           <head>
              <meta charset="utf-8">
              <title>練習使用HTML</title>
              <style>
                  /*標簽選擇器*/
                  h4 {
                      color: blue;
                      text-align: right;
                  }
      </style>
          </head>
           <body>
              <!--規定元素的行內樣式-->
              <p style="color:red;text-align:center">測試html的style屬性</p>
              <h4>h41</h4>
              <h4>h42</h4>
          </body>
       </html>

      【小編的相關推薦】

      html5 details標簽的作用是什么?<details>標簽的使用方法介紹(附使用實例)

      html table表格是什么?<table>標簽中各種屬性的使用方法

      以上就是關于HTML標簽style屬性的使用方法詳解(附具體實例)的詳細內容,更多請關注php中文網其它相關文章!


      網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。




      日韩精品一区二区三区高清