7 interesting HTML attributes (you may not know)
Tags: html, webdev
Published: 2021-02-25 04:54:19

---
title: 7 interesting HTML attributes (you may not know)
published: true
description: A list of 7 interesting HTML attributes (you may not know)
tags: html,webdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzhw0prq22yzyrrssf84.png
---

1. [`allow` in &lt;iframe&gt;](#-raw-allow-endraw-)
2. [`cite` in &lt;blockquote&gt; (and &lt;del&gt;, &lt;ins&gt;, or &lt;q&gt;)](#-raw-cite-endraw-)
3. [`datetime` in &lt;ins&gt; and &lt;del&gt;](#-raw-datetime-endraw-)
4. [`headers` in &lt;th&gt; and &lt;td&gt;](#-raw-headers-endraw-)
5. [`inputmode` in &lt;textarea&gt; or with "contenteditable"](#-raw-inputmode-endraw-)
6. [`ping` in &lt;a&gt;](#-raw-ping-endraw-)
7. [`poster` in &lt;video&gt;](#-raw-poster-endraw-)


----

## [`allow`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-allow)

The `allow` attribute defines a policy with the features available within the [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe). Some of the [values that it can have](https://developer.mozilla.org/en-US/docs/Web/HTTP/Feature_Policy): accelerometer, fullscreen, microphone, USB...

"allow" redefines how features are included in the `iframe.` It is the way moving forward and leaves the attributes `allowfullscreen` or `allowpaymentrequest` for legacy.

Example of use:

```html
<!-- 
The page in the iframe will be able to use the camera,
accelerometer, gyroscope, and geolocation; but it won't be
able to use the microphone or the magnetometer, for example.
-->
<iframe src="/url-to-load" 
        title="demo"
        width="700" 
        height="400"
        allow="accelerometer; camera; geolocation; gyroscope">
</iframe>
```

----

## [`cite`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote#attr-cite)

This is an interesting attribute for [`<blockquote>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote), but it can also be used in [`<del>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del), [`<ins>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins), or [`<q>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q) (the inline version of a quote).

The value will be an URL containing an online resource in which contains the quoted reference  (or the insertion/deletion information in the case of `<ins>` and `<del>` respectively).

It is not a required attribute, but it can be interesting if we are citing an online article or document.

Example of use:

```html
<blockquote cite="https://dev.to/alvaromontoro/don-t-just-practice-coding-n0d">
  <p>
    Coding is fundamental for a developer, but there's more
    to it than just that: soft skills are essential too!
    Actually, social and communication skills are almost as 
    critical and not as easy to master.
  </p>
</blockquote>
```

----

## [`datetime`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del#attr-datetime)

It is common to use `datetime` with [`<time>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time), but also the `<ins>` and `<del>` elements use it!

For `ins` and `del`, the `datetime` will indicate the moment of the insertion/deletion and must be a [valid date](https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#date_strings) with an [optional time string](https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#local_date_and_time_strings).

Example of use:

```html
<p>
  Marie enjoys reading books, visiting new places,
  <del datetime="2010-07-10T19:00">listening to BSB,</del> 
  <ins datetime="2020-11-08T12:00">programming in HTML,</ins>
  and a nice cup of coffee.
</p>
```

----

## [`headers`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td#attr-headers)

A table cell ([`<td>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) or [`<th>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th)), can be defined by different headers (e.g., the column and row headers are the most common), but in complex tables, there may be more than just those two. The `headers` attribute will contain a list of the headers' IDs that apply to a given cell.

This attribute is useful in complex tables as it provides context to machines. It could be interesting for assistive technologies or augmented experiences, but, unfortunately, its support is spotty. So use with caution!

Example of use:

```html
<table>
  <caption>Weekend plan</caption>
  <thead>
    <tr>
      <th></th>
      <th id="saturday">Saturday</th>
      <th id="sunday">Sunday</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td></td><th id="morning" colspan="2">Morning</th>
    </tr>
    <tr>
      <th id="hour08">8:00-10:00</th>
      <td headers="saturday morning hour08">Soccer practice</td>
      <td headers="sunday morning hour08">Reading</td>
    </tr>
    <tr>
      <th id="hour10">10:00-12:00</th>
      <td headers="saturday morning hour10">Basketball game</td>
      <td headers="sunday morning hour10">Brunch</td>
    </tr>
  </tbody>
  <tbody>
    <tr>
      <td></td><th id="afternoon" colspan="2">Afternoon</th>
    </tr>
    <tr>
      <th id="hour12">12:00-14:00</th>
      <td headers="saturday afternoon hour12">Siesta</td>
      <td headers="sunday afternoon hour12">Golf</td>
    </tr>
    <tr>
      <th id="hour14">14:00-18:00</th>
      <td headers="saturday afternoon hour14">Party!</td>
      <td headers="sunday afternoon hour14">Monday readiness</td>
    </tr>
  </tbody>
</table>
```

----

## [`inputmode`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode)

The [`<input>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) tag has different types that will trigger different keyboard inputs on mobile. For example, if you pick the type "number" when the keyboard opens on mobile, it will open with only numbers.

[`<textarea>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea) and [`contenteditable`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable) elements can get a similar effect by using the global attribute `inputmode`. So developers can decide what type of keyboard opens when the editable element is focused.

The `inputmode` property can have the values: decimal, email, none (no keyboard displayed on focus), numeric, search, tel, text (default), or url.

Examples of use:

```html
<textarea inputmode="none" name="myTextarea"></textarea>

<div contenteditable inputmode="decimal"></div>
```

----

## [`ping`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-ping)

The [`<a>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) tag has the `ping` attribute, which specifies a URL that will be called when the link is clicked. "ping" can also be used in an area inside an image map.

The URL would get a POST message with the content "PING" (literally), which can be used for tracking purposes and provide stats and information about the visitor and how they used the site.

One big problem with this attribute is that [Firefox does not support it](https://caniuse.com/ping), which leaves out a good number of users.

Example of use:

```html
<a href="https://twitter.com/alvaro_montoro" ping="/url-stats.php">
  Check my twitter profile
</a>
```
----

## [`poster`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-poster)

One (relatively) common mistake developers make when adding a video to a webpage is having an image and replacing it with the [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) once clicked. This is not flexible or efficient as the video won't start loading until it is placed on the page.

The `poster` attribute would be the way to go. It will be the URL of an image, replaced when the video starts playing. It looks the same, but it provides more control over the video and how it is loaded.

Example of use:

```html
<video controls poster="link-to-poster-image.jpg">
  <source src="link-to-video.mp4" type="video/mp4">
  <source src="link-to-video.webm" type="video/webm">
  Sorry, your browser doesn't support embedded videos.
</video>
```