HEAD – A guide to <head> elements
htmlhead.dev
htmlhead.dev
Instead we find many of those tags (title, description, author, etc.) hidden behind the namespace of some corporations.
It looks like they don't follow their own advice:
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0">maximum-scale has only three valid uses:
1. extreme values, like 5.0, if a browser misdetects that zooming that far is useful when it isn't (rare)
2. pure-app websites like maps or video games that have alternative scaling arrangements and browser pinch-zoom gets in the way.
3. there is no number three, and the thing you are thinking of is incorrect.
maximum-scale is an automatic usability and accessibility fail otherwise, you are bad and should be made to feel bad if you use it.
OMG, I thought how much money is this company losing because their website intentionally disables a built in feature!?
Only asking because it’s a friend’s site and I helped him build the quote modal which you currently can’t zoom.
I guess they won't know what business they're losing 'cos they won't know people are leaving the site because of that specific issue.
If they're on the ball, their tracking might be good enough that they can see people leaving on that step and try to zoom in on that problem area.
If they're really good, they might spot they get no sales from users with a certain resolution and try it out for themselves.
Very odd.
I wish more people realized this. As somebody that's visually impaired, it makes mobile browsing quite painful for me.
https://webkit.org/blog/7367/new-interaction-behaviors-in-io...
maximum-scale=1.0 causes the page to be unscalable on mobile and is almost never what you want.
Other "pages" (as rough-sketch descriptions) I can imagine: colors.dev, cacheperf.dev, unicode.dev, rdf/microdata.dev, parsing.algorithms.dev, querystring.dev (a micro reference for sure).
Likewise, "micro" web tools which I'm sure exist as a concept I don't know already would be very convenient (xml->json converter, linters/viewers/auditors of all sorts).
> "...width=device-width, initial-scale=1..."
This is a surprising bit of opinionation to an otherwise decent presentation of head elements. Websites render quite nicely on modern phones without this line, but they generally render as if they are on a desktop browser. Using the above meta tag allows you easy access to modern approaches to mobile development.
I've never had that line do something I didn't want. Is there a reason mobile browsers don't automatically just do whatever that line does? Seems like the opt-in behavior should be "yes, render me like I'm a desktop site on a tiny monitor" rather than opt-out.
If you look at the original iPhone demo in 2007[0], the original intent was to render full web pages on the screen and rely on the double-tap-to-zoom to read content.
The article that's generally credited with naming and mainstreaming Responsive Web Design[1] didn't come until 2010.
What exactly does that mean? It reads almost like marketing copy for a new framework.
Once the browser is being honest about its screen, you can use CSS media queries and the like to do responsive web design, giving mobile devices content that fits them and is touch-friendly. If the browser is claiming a desktop-sized viewport, your options are to either serve a desktop layout or to do User-Agent sniffing and the like.
[1] All high-res devices today maintain a distinction between a CSS pixel (approximately 1/96 in.) and a device pixel, and they give their resolution in CSS pixels. This is dishonest from the point of view of 1995, but it’s convenient and it’s what web designers expect today.
If you wanted to avoid using that for some reason, there is a very effective (~99% coverage) way to do it and make your site render perfectly on mobile. In your application, simply check the user agent for "mobile" and insert whatever resources you prefer to adjust for mobile (perhaps an entirely different design for example, as is sometimes appropriate) and failing that switch to desktop view resources.
For common caching (you don't want to cache one universal copy of a page for desktop and serve that to mobile), if you're using Nginx as a web server and for caching, map a mobile value based on the detection of the keyword "mobile" in the user agent, something like:
Map $http_user_agent $mobilekey {"~*Mobile" mobile; default desktop;}
Staple that $mobilekey value to the proxy_cache_key to generate two cache versions, one for mobile, one for desktop. For most sites this is a low burden expense. The map approach also avoids the various pitfalls of attempting to use IFs in Nginx, so it's extremely performant.
This approach has obvious downside risk, such as if the popular browsers decide to drop the mobile keyword from their user agent strings (there are other simple ways to target the user agent that would solve that change however). The industry overwhelmingly disagrees with targeting the user agent like this, however it works perfectly well and has for a long time.
<meta name="viewport" content="width=device-width, initial-scale=1">
Please no. IMO this makes most pages unusable on mobile. Most websites, e.g. news websites with long-form articles, shouldn't be using mobile pages / responsive design / zoomed-in layout at all. Web apps (Twitter, GMail), maybe. But most mobile pages are far more unusable than desktop versions (looking at you, Facebook and Reddit).Do you mean you actually prefer having to scroll left/right/left/right/left/right when reading a long article?
The early Android browser used to actually reflow columns to fit on the mobile screen when you zoomed in, but it lost that in the transition to Chrome.
The 6 lines comes from iOS Safari defaulting to emulating an approx 800 point wide display (on a 400 point wide display)
But, I also have no problem with Facebook's mobile site, so maybe I just don't see the same problems as you are seeing.
The only pages I prefer in mobile view are ones that get rid of their backgrounds and useless white space on the sides. I use HN in mobile view, but the difference is small enough that it doesn't matter.
Even the htmlhead.dev site that is linked works better in desktop mode, because it doesn't force you to scroll the code tags.
Is Dreamweaver still a thing? I haven't heard of it in years, many years.
https://helpx.adobe.com/dreamweaver/using/whats-new.html
Although, it looks like their cumulative 2019 updates are limited to the following headlines between the two:
1) added support for HTML tag highlighting inside PHP code
2) bootstrap CSS support.
... I was surprised to see it was still alive.
Side note in 2012 my boss forced me to use Dreamweaver and took a lot of persuading to let us use the new (at the time) Sublime text. Good times.
It's under Tools > Deployment
Source: I use it daily.
Dreamweaver is open-edit-push back. Perfect when you have to make a change to a site and don't want all of the fiies locally.
AFAIK it's the best non-code way to create sites without being tied to a hosting platform or messing with Wordpress plugins.
BTW; not all UTF-8 text has a byte-order mark, I would say most of them don't.
Guessing between valid UTF-8 and Latin-1 is only ever ambiguous when there are multiple non-ASCII characters in a row and all those sequences are made up of a lead byte with the correct number of trailing bytes. How often is that a problem for you in practice?
What I don't get is why so many say it is required in the head, even when you manage to set the header.
Or we could have a default of UTF-8.
I don't dispute that it can be nice. I am just curious why so many say it is required.
Another use case might be content that is authored in a content management system. Perhaps it's the easiest way to carry your intended charset to the destination.
You don't have to put anything in a head tag, you don't even need a head tag, but it's a good idea to have one and to at least add a charset meta tag. Everything is optional, though.
The entire point of it is for you to share metadata about your page with the browser.
<link href=data:, rel=icon>
This is the smallest possible "null" favicon. It causes the browser to display nothing and ensures 0 HTTP requests for the favicon!Why is this included in these guidelines?
EDIT: See reply. Thanks!
<!-- Icon in the highest resolution we need it for --> <link rel="icon" sizes="192x192" href="/path/to/icon.png">
<!-- Apple Touch Icon (reuse 192px icon.png) --> <link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png">
I thought there was literally like a dozen different sizes and names to support all different Apple and Android devices.
Still, I know what you’re talking about and it’s awful how many “gurus” suggest all that noise.
[0] https://realfavicongenerator.net/faq [1] https://htmlhead.dev/#icons
Then again were all slaves to the whims of Alphabet and Facebooks for traffic.
I recently read somewhere that for backwards compatibility reasons no new element types can be added within `head`. This causes a lot of overloading on the existing ones for elements like <link />.
I don't have any supporting evidence though.
<html>
<head>
<title>I am in the head</title>
<foo>I am in the body!</foo>
</head> <- this is a parse error and is ignored <title>I am in the head</title>
<foo>I am in the body</foo>
I've described how this works for SGML here [1], but it also applies to HTML.[1]: http://sgmljs.net/docs/sgml-html-tutorial.html (see slides linked from TALK)
(Explanation: https://css-tricks.com/using-css-without-html/ )
Actually though, for the server-side processed stuff we are still using <base> to make sure that /fancy/bespoke/url/style URLs doesn't try to grab assets from /fancy/bespoke/url/style/styles/main.css - I guess it's less that I don't use it and more that now-a-days I rarely set it to anything other than domainname since I'll just materialize a new subdomain if I need to do something fancy.
tl;dr you should not expect to actually be targeted with an ICBM unless you foolishily also include elevation information.
It just gave me a chuckle thinking about it
Thanks for the guide!
Less seriously, sometimes it's referred to as "Oh, whatever happened to XHTML 2.0, I was so looking forward to that, oh well guess we're using HTML5" but this is usually at conferences.
sure, I've heard that context too