visit
<input type="file" accept=".jpg, .png">
Only used with file
type of the<input>
tag. Takes in a comma-separated list of one or more file types. To allow all files of specific media type, use accept="image/*"
.
<input type="text" autofocus>
Only one element in the document or dialog may have the autofocus
attribute. If applied to multiple elements the first one will receive focus.
<input type="text" inputmode="url" />
<input type="text" inputmode="email" />
<input type="text" inputmode="numeric" />
This allows a browser to display an appropriate virtual keyboard.
Specifies a regular expression that the <input>
value is checked against on form submission.
<input name="username" id="username" pattern="[A-Za-z0-9]+">
<form action="/send_form.js">
Username: <input type="text" name="username" required>
<input type="submit">
</form>
<input name="credit-card-number" id="credit-card-number" autocomplete="off">
For the full list of available autocomplete
values, see .
<input type="file" multiple>
You can use it with file
and email
types of <input>
and the <select>
tag.
<a href="document.pdf" download>Download PDF</a>
<div contenteditable="true">
This text can be edited by the user.
</div>
<input type="text" id="sports" name="sports" value="golf" readonly>
A user can still tab to it, highlight it, and copy the text from it. To forbid those actions, use the disabled
attribute, instead.
<p hidden>This text is hidden</p>
<p contenteditable="true" spellcheck="true">Myy spellinng is checkd</p>
Typically, all the non-editable elements are not checked, even if the spellcheck
attribute is set to true
and the browser supports spellchecking.
<footer><p translate="no">Printing Works, Inc</p></footer>
An example use case would be your company name, book titles, locations, etc.
<img src="//cdn.mysite.com/media/image.jpg" loading="lazy">
eager
is the default behavior, lazy
is used to defer (aka lazy loading).
<img src="imageafound.png" onerror="this.onerror=null;this.src='imagenotfound.png';"/>
The this.onerror=null
is used to prevent the loop if the fallback image itself is not available.
<video
src="//cdn.mysite.com/media/video.mp4"
poster="image.png">
</video>
If not specified, nothing is displayed until the first frame is available, then the first frame is shown as the poster frame.
<audio controls
<source src="track11.mp3" type="audio/mpeg">
</audio>
<video autoplay
src="//cdn.mysite.com/media/myvideo.mp4"
poster="image.png">
</video>
<audio loop
<source src="track323.mp3" type="audio/mpeg">
</audio>
<blockquote cite="//mysite.com/original-source-url">
<p>Some awesome quote</p>
</blockquote>
<p>
My plans for 2021 include visiting Thailand,
<del datetime="2021-01-01T18:21">creating 6 courses,</del>
<ins datetime="2021-02-02T14:07">writing 12 articles.</ins>
</p>
<p>I will evaluate the completion on <time datetime="2021-12-31"></time>.</p>
When used with the <time>
element, it represents a date and/or time in the machine-readable format.
<script src="script.js" async></script>
The async
attribute only has an effect on external scripts (src
attribute must be present).
<script src="script.js" defer></script>
The defer
attribute only has an effect on external scripts (src
attribute must be present).
<script>
const allowDrop = (e) => e.preventDefault();
const drag = (e) => e.dataTransfer.setData("text", e.target.id);
const drop = (e) => {
var data = e.dataTransfer.getData("text");
e.target.appendChild(document.getElementById(data));
}
</script>
<div ondrop="drop(event)" ondragover="allowDrop(event)" style="width:150px; height:50px; padding: 10px; border:1px solid black"></div>
<p id="drag" draggable="true" ondragstart="drag(event)">Drag me into box</p>