Search
Semantic menu context
11.11.2021
Scott digs into the history of the <menu> element. He traced it as far back as HTML 2 (!) in a 1994 changelog. The vibe then, it seems, was to mark up a list. I would suspect the intention …
The post Semantic menu context appeared first on CSS-Tricks. You can support CSS-Tricks...
Favicons: How to Make Sure Browsers Only Download the SVG Version
5.11.2021
Šime Vidas DM’d me the other day about this thread from subzey on Twitter. My HTML for favicons was like this:
<!-- Warning! Typo! --<link rel="icon" href="/favicon.ico" size="any"<link rel="icon" href="/favicon.svg" type="image/svg+xml"
The attribute size is a typo there...
enterkeyhint
5.11.2021
I only just recently learned the enterkeyhint attribute on form inputs was a thing! It seems like kind of a big deal to me, as crafting HTML form markup is a decent slice of a front-end developer’s life, and this …
The post enterkeyhint appeared first on CSS-Tricks. You can support...
Proxying Third-Party JavaScript as First-Party JavaScript (and the Potential Effect on Analytics)
2.11.2021
First, check out how incredibly easy it is to write a Cloudflare Worker to proxy another URL:
addEventListener("fetch", (event) ={
event.respondWith(
fetch("https://css-tricks.com")
);
});
It doesn’t have any error handling or anything, but hey, it works:
Now imagine how …
The...
The Options for Password Revealing Inputs
6.10.2021
In HTML, there is a very clear input type for dealing with passwords:
<input type="password"
If you use that, you get the obfuscated bullet-points when you type into it, like:
••••••••
That’s the web trying to help with security. If …
The post The Options for Password Revealing...
Amazon Is Selling Used Xbox Series Xs At Scalper Markup Prices
30.9.2021
Almost a year after the PS5 and Xbox Series X came out they’re still incredibly hard to find, and expensive, including at Amazon where the monopolistic retailer appears to be selling at least a few Microsoft consoles for roughly $1,000, or twice what they’re actually supposed to cost.Read more
Building a Form in PHP Using DOMDocument
14.9.2021
Learn how to build an HTML form in PHP using DOMDocument — a structured and expressive way to build logical markup.
The post Building a Form in PHP Using DOMDocument appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter
“Just in Time” CSS
10.9.2021
I believe acss.io is the first usage of “Atomic CSS” where the point of it is to be a compiler. You write CSS like this:
<div class="C(#fff) P(20px)"text
</div
And it will generate CSS like:
.C\(\#333\) {
color: #333;
…
The post “Just in Time” CSS appeared...
Native JavaScript Routing?
23.8.2021
We can update the URL in JavaScript. We’ve got these APIs:
// Adds to browser history
history.pushState({}, "About Page", "/about");
// Doesn't
history.replaceState({}, "About Page", "/about");
JavaScript is also capable of replacing any content in the DOM....
The Big Gotcha With Custom Properties
19.8.2021
I’ve seen this confuse more than a handful of people recently, including myself, so I’m making sure it’s written down.
Let’s chuck a couple of custom properties into CSS:
html {
--color-1: red;
--color-2: blue;
}
Let’s use them right …
The post The...
CSS Nesting, specificity, and you
10.8.2021
Here’s Kilian Valkhof on CSS nesting which isn’t available in browsers yet, but will be soon. There are a few differences he notes between CSS nesting and nesting in Sass or Less though. Take, for example, the following code:
div
…
The post CSS Nesting, specificity, and you appeared...
Choice Words about the Upcoming Deprecation of JavaScript Dialogs
9.8.2021
It might be the very first thing a lot of people learn in JavaScript:
alert("Hello, World");
One day at CodePen, we woke up to a ton of customer support tickets about their Pens being broken, which ultimately boiled down to …
The post Choice Words about the Upcoming Deprecation of JavaScript...
ECMAScript proposal: JSON modules
21.7.2021
Dr. Axel Rauschmayer looks at JSON modules, which is already live in Chrome 91 (but nothing else). It looks just like an ES Modules-style import, only you asset the type at the end.
import configData from './config-data.json' assert {type:
…
The post ECMAScript proposal: JSON modules...
WordPress Admin Warnings in the Block Editor
16.7.2021
We sent out an email the other week that ultimately had a <video> in the HTML markup. We send the newsletter by creating it here in the WordPress block editor, which is fetched through RSS-to-Mailchimp. Mailchimp dutifully sent it out, …
The post WordPress Admin Warnings in the Block...
Using the Specificity of :where() as a CSS Reset
12.7.2021
I don’t know about you, but I write these three declarations many times in my CSS:
ul {
padding: 0;
margin: 0;
list-style-type: none;
}
You might yell at me and say I can just put those in my CSS …
The post Using the Specificity of :where() as a CSS Reset appeared first on CSS-Tricks....
Body Toggle
6.7.2021
I appreciate the clarity of this trick that Mikael Ainalem posted over on Reddit:
It’s a one-liner that toggles the class on the <body> so you can mock up different states and toggle between them on click.
<body onclick="this.classList.toggle("active");"
Could …
The post...
What does `font: 110%/1.4 system-ui` mean?
30.6.2021
I use this line, or one like it, in a lot of quick demos. Not that it’s not a production-worthy line of code—I just tend to be a bit more explicit on bigger projects.
html {
font: 110%/1.4 system-ui;
}
…
The post What does `font: 110%/1.4 system-ui` mean? appeared first...
System *Things
29.6.2021
I think we’re all largely aware of named colors in CSS:
color: OldLace;
background: rebeccapurple;
I guess you’d just call those “named colors” in CSS.
Those aren’t the only kind of named colors there are though. Some of them …
The post System *Things appeared...
target=”blank”
9.6.2021
Does that make your eye twitch a little bit? Like… it’s a typo. It should be target="_blank" with an underscore to start the value. As in…
<a target="_blank" href="https://codepen.io"Open CodePen in a New Tab
</a
Welp, that’s correct syntax!…
The post...
To $ or Not to $: Displaying Terminal Code Snippets
27.5.2021
It’s very popular to put a $ on lines that are intended to be a command in code documentation that involves the terminal (i.e. the command line).
Like this:
$ brew install somepackage
The point of that is that it …
The post To $ or Not to $: Displaying Terminal Code Snippets appeared...