HTML Tips (2020)
71–80 of 136 posts
Re: HTML Tips (2020)
#72I want a cachebust="yes" attribute that invalidates an image when it changes, yet never contacts the server when the image is unchanged.
PHP code for this kind of thing might look like this: function auto_version($urlpath) {
// get a filesystem path
$fspath = $_SERVER['DOCUMENT_ROOT'] . $urlpath;
// if file doesn't exist, don't mess with the url
if (!file_exists($fspath)) {
return $urlpath;
}
// insert last modified timestamp
$mtime = filemtime($fspath);
return preg_replace('{\\.([^./]+)$}', ".$mtime.\$1", $urlpath);
}
Then in .htaccess or equivalent to strip the timestamp back off before serving the file: RewriteRule ^(.*)\.[\d]{10}\.(css|js|png)$ $1.$2 [L]
Whenever the file is updated you automatically start serving a new link which points to the same file, and otherwise you can rely on the browser caching. You don't need to mess around with ?params, which also helps semantically because those incorrectly suggest that the resource is dynamic.Re: HTML Tips (2020)
#73Earlier quoted context omitted.
And also cross browser support for the spec in general - eg desktop Safari doesn't implement that date picker, or any special treatment of input type="date" at all.
I don't have a modern Safari in front of me to check, but Can I Use alleges they're about on par with Firefox as of 14.1: https://caniuse.com/?search=Input%20date Does that mean only fully up-to-date macOS gets it, or do Safari versions move independent of the OS?
In rare cases, Safari features require a capability only available on the latest macOS.
Re: HTML Tips (2020)
#74> 5. HTML Native Search I've dynamically updated on a site, only to find out that browsers will only show options that strictly begin with whatever you've typed into the . When you want to do Google Search-esque suggestions, that's a problem. I don't know how to override that to force it to show all options.
There's so much stuff in HTML that's almost good enough to replace things we use Javascript for. We should also have had built-in pagination and sorting on tables, like, years ago, with some kind of (optional, if your data aren't all available on the initial page load) back-end spec for how the requests will be shaped and for delivering the data. An awful lot of "AJAX" Javascript use could just be frames and iframes,…
IMO we would be better off moving most of these things out of the browsers and into some kind of web component standard.
Re: HTML Tips (2020)
#75Earlier quoted context omitted.
And also cross browser support for the spec in general - eg desktop Safari doesn't implement that date picker, or any special treatment of input type="date" at all.
Apparently it will be supported in the next version! https://webkit.org/blog/11648/new-webkit-features-in-safari-...
And iOS 14.5 (well, 14.5.1) is also current: https://support.apple.com/en-ca/HT211808#1451
But we'll have to wait a few weeks to months before all Safari users upgrade and see the latest improvements.
Re: HTML Tips (2020)
#76> 5. HTML Native Search I've dynamically updated on a site, only to find out that browsers will only show options that strictly begin with whatever you've typed into the . When you want to do Google Search-esque suggestions, that's a problem. I don't know how to override that to force it to show all options.
on firefox it finds all phrases containing the entered string
Re: HTML Tips (2020)
#77Awesome list! The ' tip reminds me that I wish there was a better way to do nested list numbering of the kind you'd likely find in a table of contents, such as "1.1.2" and so on. As far as I'm aware there's no simple way to do this natively without using CSS or JS to change the list item prefix.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Lists_a...
Re: HTML Tips (2020)
#78Is there any good 'linear'(with a clear learning path, e.g. course/book, as opposed to MDN) resource to learn modern HTML/CSS? Preferably not one starting at Hello World. The thing is I'm primarily a BE developer but I have to do some front-end tasks every now and then and I often catch myself reinventing the HTML5 wheel.
To build upon this question, more broadly: I'm also someone who's done quite a bit of HTML but it definitely isn't my day job. Finding good info is quite hard whenever I do want to make some site: most of the time I end up on reference pages but they don't give a good overview, whereas beginner's tutorials might have the piece of info I'm missing somewhere on the middle of part 7 (I don't have the patience for that).…
Its author has been in the web dev field for decades and has written multiple books on the topic. She has got some chapters written by experts in respective fields (CSS by Eric Meyer and so on)
Re: HTML Tips (2020)
#79Some remarks, with some opinions, some caveats, and some extra info that I find interesting: 1. Lazy loading: generally speaking, just don’t do this. It’s much better than doing it in JavaScript (especially when combined with a blurry image until it loads, which I and many others find surprisingly disconcerting), but if you’re not very close to the server (which very commonly means “if you’re not in the USA”) then it…
> In a situation like this, the ideal is to put the radio button inside its label, and make the label `display: block`, or something else that achieves this effect (if done carefully, you might even find `display: grid` suitable nowadays). This is actually not great for accessibility. It may be okay for some screen readers if you also populate the for/id attributes, but even then you should test to be sure. Edit to a…
Re: HTML Tips (2020)
#80Earlier quoted context omitted.
There's so much stuff in HTML that's almost good enough to replace things we use Javascript for. We should also have had built-in pagination and sorting on tables, like, years ago, with some kind of (optional, if your data aren't all available on the initial page load) back-end spec for how the requests will be shaped and for delivering the data. An awful lot of "AJAX" Javascript use could just be frames and iframes,…
In Python there's a saying: the standard library is where modules go to die. That effect applies even more so for browser builtins. IMO we would be better off moving most of these things out of the browsers and into some kind of web component standard.
This way, modules can declare that they need certain functionality and then the end user provides it: instead of npm-style infinitely-deep dependency trees.
https://gbracha.blogspot.com/2009/06/ban-on-imports.html?m=1