HTML
Collections
-
Tip - Use fetchpriority=high to load your LCP hero image sooner
-
Responsive Images 101, Part 4: Srcset Width Descriptors
- width of the image sources
-
Two ways to safely break a long word in HTML
<wbr>­- CSS hyphens
-
Three attributes for better web forms
- inputmode, enterkeyhint, and autocomplete.
-
HTMHell - A collection of bad practices in HTML, copied from real websites.
-
Effortlessly Support Next Gen Image Formats
- use the
pictureelement
- use the
-
A Blog Post With Every HTML Element
<base>
-
Youtube video embedding harm reduction
<iframe credentialless allowfullscreen referrerpolicy="no-referrer" sandbox="allow-scripts allow-same-origin" allow="accelerometer 'none'; ambient-light-sensor 'none'; autoplay 'none'; battery 'none'; browsing-topics 'none'; camera 'none'; display-capture 'none'; domain-agent 'none'; document-domain 'none'; encrypted-media 'none'; execution-while-not-rendered 'none'; execution-while-out-of-viewport ''; gamepad 'none'; geolocation 'none'; gyroscope 'none'; hid 'none'; identity-credentials-get 'none'; idle-detection 'none'; local-fonts 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; otp-credentials 'none'; payment 'none'; picture-in-picture 'none'; publickey-credentials-create 'none'; publickey-credentials-get 'none'; screen-wake-lock 'none'; serial 'none'; speaker-selection 'none'; usb 'none'; window-management 'none'; xr-spatial-tracking 'none'" , csp="sandbox allow-scripts allow-same-origin;" width="560" height="315" src="https://www.youtube-nocookie.com/embed/jfKfPfyJRdk" title="lofi hip hop radio 📚 - beats to relax/study to" frameborder="0" loading="lazy" ></iframe> -
Clarifying the Relationship Between Popovers and Dialogs
- Popover is an umbrella term for any kind of on-demand popup.
- Dialog is one type of popover — a kind that creates a new window (or card) to contain some content.
- Modal: A dialog with an overlay and focus trapping
- Non-Modal: A dialog with neither an overlay nor focus trapping
- Alert Dialog: A dialog that alerts screen readers when shown. It can be either modal or non-modal.
-
Control the Viewport Resize Behavior on mobile with
interactive-widget -
Relatively New Things You Should Know about HTML Heading Into 2025
-
Use "translate" to turn off element translations
translate="no"attribute
-
Better Browser Caching with No-Vary-Search
Imagine a landing page that is heavily used in campaigns, ads, email, and social posts:/offer?utm_source=google/offer?utm_source=chatgpt/offer?utm_source=linkedin
If those all return the same page, you can tell the cache to ignore
utm_source:No-Vary-Search: params=("utm_source")
<a download> 동작 규칙
- Same-origin URL (같은 출처):
download="filename.ext"로 파일명 지정 가능- 브라우저가 해당 파일명을 사용해 다운로드
- Cross-origin URL (다른 출처):
download속성 무시됨- 서버의
Content-Disposition헤더가 우선 적용 Content-Disposition: attachment; filename="server-filename.ext"
Amazing HTML5 Features That Just 3% of Developers Knows
- datalist
<input type="file" accept=".png, .jpg">- details
- meter
- progress
Working with forms with vanilla JavaScript
... Form fields must have a name attribute to be included in the object. Otherwise, they’re skipped. The id property doesn’t count.
Those HTML Attributes You Never Use
- The
enterkeyhintAttribute For Virtual Keyboards - The
titleAttribute On Stylesheets - The
citeAttribute For The<blockquote>And<q>Elements - Attributes For Custom Ordered Lists
- reversed, start, type, value
- The
downloadAttribute For The<a>Element - The
decodingAttribute For The<img>Element - The
loadingAttribute For The<iframe>Element - The
formAttribute For Form Fields - The
citeAnddatetimeAttributes For Deletions/Insertions - The
labelAttribute For The<optgroup>Element - The
imagesizesAndimagesrcsetAttributes For Preloading Responsive Images - The
crossoriginattribute which can apply to multiple elements, including<audio>,<img>,<link>,<script>, and<video>, providing support for cross-origin resource sharing (CORS); - The
titleattribute for<dfn>and<abbr>; - The new
disablepictureinpictureattribute for the<video>element; - The
integrityattribute for scripts, which helps the browser verify that the resource hasn’t been improperly manipulated; - The
disabledattribute for the<fieldset>element, to easily disable multiple form elements simultaneously; - The
multipleattribute for email and file inputs.
template
<template> is special, very different from display: none; and definitely has a few advantages:
-
The elements in it are parsed into a different document and are inert until cloned or adopted into the main document. Images don't load, scripts don't run, styles don't apply, etc. This is very important.
-
The content model validation is turned off, so a
<template>can contain a <td> -
Mutation observers and events are not fired for parsed content.
-
The
<template>element itself can appear anywhere, including restricted content elements like <table> -
Other HTML processing libraries generally know to ignore
<template>, unlike other content just hidden with CSS.
This makes parsing faster and guaranteed to have no side effects, and conveys the correct semantics to the browser and tools.
Semantics
In addition - “template” also conveys correct semantics to the other developers working on the codebase. If I see an html at the bottom with “display: none” it’s very possible that the intended usage is to leave it there and set “display: block”, ie a modal. “display: none” doesn’t convey “clone me”, but “template” does.
Forms
- Forms 101: More tags useful in forms -
<fieldset>,<legend>
Inputs
- Scripted
<INPUT>Matching With Native Error Reporting - Build an OTP input field
- Form fields: File input fields
- Form fields: Autocompleting form fields
- Fine-tuning Text Inputs
How to Use Responsive HTML Video (...and Audio!)
<video>
<source media="(min-width: 2000px)" src="large.webm" type="video/webm" />
<source media="(min-width: 2000px)" src="large.mp4" type="video/mp4" />
<source media="(min-width: 1000px)" src="medium.webm" type="video/webm" />
<source media="(min-width: 1000px)" src="medium.mp4" type="video/mp4" />
<source src="small.webm" type="video/webm" />
<source src="small.mp4" type="video/mp4" />
</video>
Children
- 11 HTML best practices for login & sign-up forms
- 24 Powerful HTML Attributes Every Senior Web Engineer Should Master!
- A practical guide to using shadow DOM
- All You May Need Is HTML
- HTML First
- How To Choose The Right Tag
- How to Favicon in 2023: Six files that fit most needs
- How to prevent buttons from causing a form to submit with HTML
- I bet you didn't know about these 15 HTML features.
- Should I Use a Button or a Link?
- Techniques to Break Words
- Text Fragments
- You don't need a modal window