您可以使用內嵌 <style> 區塊和標準 CSS,設定傳送至 Gmail 的電子郵件樣式。支援大多數 CSS 選擇器、屬性和媒體查詢。Gmail 可能會忽略不支援的 CSS 屬性和選取器。
如需支援的 CSS 屬性和查詢完整清單,請參閱參考指南。
CSS 選擇器
您可以使用 CSS 選擇器子集套用樣式。Gmail 支援類別、元素和 ID 選取器。
範例
<html>
  <head>
    <style>
      .colored {
        color: blue;
      }
      #body {
        font-size: 14px;
      }
    </style>
  </head>
  <body>
    <div id='body'>
      <p>Hi Pierce,</p>
      <p class='colored'>This text is blue.</p>
      <p>Jerry</p>
    </div>
  </body>
</html>
CSS 媒體查詢
你可以使用標準 CSS 媒體查詢,調整電子郵件的樣式,以配合使用者目前的裝置。Gmail 支援針對螢幕寬度、方向和解析度的查詢。
範例
<html>
  <head>
    <style>
      .colored {
        color: blue;
      }
      #body {
        font-size: 14px;
      }
      @media screen and (min-width: 500px) {
        .colored {
          color:red;
        }
      }
    </style>
  </head>
  <body>
    <div id='body'>
      <p>Hi Pierce,</p>
      <p class='colored'>
        This text is blue if the window width is
        below 500px and red otherwise.
      </p>
      <p>Jerry</p>
    </div>
  </body>
</html>
支援的 CSS 屬性和查詢
Gmail 支援下列 CSS 屬性:
- azimuth
 - background
 - background-blend-mode
 - background-clip
 - background-color
 - background-image
 - background-origin
 - background-position
 - background-repeat
 - background-size
 - border
 - border-bottom
 - border-bottom-color
 - border-bottom-left-radius
 - border-bottom-right-radius
 - border-bottom-style
 - border-bottom-width
 - border-collapse
 - border-color
 - border-left
 - border-left-color
 - border-left-style
 - border-left-width
 - border-radius
 - border-right
 - border-right-color
 - border-right-style
 - border-right-width
 - border-spacing
 - border-style
 - border-top
 - border-top-color
 - border-top-left-radius
 - border-top-right-radius
 - border-top-style
 - border-top-width
 - border-width
 - box-sizing
 - break-after
 - break-before
 - break-inside
 - caption-side
 - clear
 - 顏色
 - column-count
 - column-fill
 - column-gap
 - column-rule
 - column-rule-color
 - column-rule-style
 - column-rule-width
 - column-span
 - column-width
 - 資料欄
 - 方向
 - 顯示
 - 高度
 - empty-cells
 - float
 - 字型
 - font-family
 - font-feature-settings
 - font-kerning
 - font-size
 - font-size-adjust
 - font-stretch
 - font-style
 - font-synthesis
 - font-variant
 - font-variant-alternates
 - font-variant-caps
 - font-variant-east-asian
 - font-variant-ligatures
 - font-variant-numeric
 - font-weight
 - 高度
 - image-orientation
 - image-resolution
 - ime-mode
 - 隔離
 - layout-flow
 - layout-grid
 - layout-grid-char
 - layout-grid-char-spacing
 - layout-grid-line
 - layout-grid-mode
 - layout-grid-type
 - letter-spacing
 - line-break
 - line-height
 - list-style
 - list-style-position
 - list-style-type
 - margin
 - margin-bottom
 - margin-left
 - margin-right
 - margin-top
 - marker-offset
 - max-height
 - max-width
 - min-height
 - min-width
 - mix-blend-mode
 - object-fit
 - object-position
 - opacity
 - 大綱
 - outline-color
 - outline-style
 - outline-width
 - overflow
 - overflow-x
 - overflow-y
 - padding
 - padding-bottom
 - padding-left
 - padding-right
 - padding-top
 - page-break-after
 - page-break-before
 - page-break-inside
 - 暫停
 - pause-after
 - pause-before
 - 投球
 - pitch-range
 - 名言佳句
 - richness
 - 說話
 - speak-header
 - speak-numeral
 - speak-punctuation
 - speech-rate
 - stress
 - table-layout
 - text-align
 - text-align-last
 - text-autospace
 - text-combine-upright
 - text-decoration
 - text-decoration-color
 - text-decoration-line
 - text-decoration-skip
 - text-decoration-style
 - text-emphasis
 - text-emphasis-color
 - text-emphasis-style
 - text-indent
 - text-justify
 - text-kashida-space
 - text-orientation
 - text-overflow
 - text-transform
 - text-underline-position
 - unicode-bidi
 - vertical-align
 - voice-family
 - white-space
 - width
 - word-break
 - word-spacing
 - word-wrap
 - writing-mode
 - 縮放
 
支援的媒體查詢
支援的類型
- 全部
 - 螢幕
 
支援的查詢
- min-width
 - max-width
 - min-device-width
 - max-device-width
 - 方向
 - min-resolution
 - max-resolution
 
支援的關鍵字
- 和
 - 唯一