你不知道的 HTML(1)

meter 標籤

meter 標籤能夠用來表示已知範圍的數值,例如:html

<meter min="0" max="500" value="350"></meter>

在 Chrome 上會顯示爲:antd

<meter />

required 屬性

有的時候 React、Vue、antd 等框架和庫用的多了,對原生的 html 標籤反而不熟悉了。事實上,原生的 html 標籤也支持表單的必填校驗,設置 required 屬性爲 true 便可。框架

<form>
  <input type="text" id="username" name="username" required="required" />
  <input type="submit" />
</form>

若是輸入框中沒有填值就點擊「提交」按鈕,輸入框下方會出現如下提示:ui

required

download 屬性

download 屬性主要被用在 link 標籤裏,來使用戶能夠從網頁上下載文件。例如:spa

<div>
  <a href="image.png" download="imageName">下載圖片</a>
</div>

能夠把新的文件名做爲值傳給 download 屬性。code

abbr 標籤

abbr 標籤用於表明縮寫,而且能夠經過可選的 title 屬性提供完整的描述。orm

當鼠標 hover 在 abbr 標籤上時,鼠標上會懸浮出 title 的屬性中的內容。htm

<p>
  You can use <abbr title="Cascading Style Sheets">CSS</abbr> to style your
  <abbr title="HyperText Markup Language">HTML</abbr>.
</p>

abbr

相關文章
相關標籤/搜索