My Current HTML Boilerplate
matuzo.at
matuzo.at
<html lang="en" class="no-js">
...
<script type="module">
document.documentElement.classList.remove('no-js');
document.documentElement.classList.add('js');
</script>
It's so simple but so effective. Will be copying that.Edit: To be clear, Modernizr isn't a big library like jQuery and you can specify the thing you want to detect, so you can cut it down, but it's still pointless if you just want to know if JS is enabled or not.
Basically, serve a page with formatting done via table layout, and then rewrite it with javascript in the client to use more modern layout tools, depending on which features were available on the browser.
> [not] for a decade
Agreed, probably longer. How old is Modernizr?
Who asked?
Edit: Your blog doesn't even use SSL...
I’ve had the “how to deal with folks who disable JavaScript” discussion for well over 10 years and the answer in every shop I’ve worked in has always been the same... don’t bother. And it was the developers themselves making that call, not the “business people”.
But yeah, GP, get a Let's Encrypt certificate for the sake of your readers!
What http site is left we can go to when isp or WiFi greets with a welcome login page. Going to https sites gives an error.
You are also welcome to use my html boilerplate:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="blue-white.css">Otherwise… example.com, maybe. I guess we'll see how long the http version of that lasts.
I assume ISPs will get around to this a few decades after implementing IPv6.
<noscript> is pretty much a feature of the HTML parser. It disappears. The DOM representation doesn’t include a <noscript> element, so you can’t style it. (This is also why you can’t use <noscript> in the XML syntax of HTML. If you don’t know about the XML syntax, I’ll simplify and say it roughly means what was commonly called XHTML.)
What makes it even less useful is that the absence of the <noscript> content doesn’t mean that your scripts are being executed. If you use something like uMatrix or uBlock Origin to block certain types of scripts, for example, you might find that none of the scripts execute, but that the <noscript> content is also not loaded, because it could have executed some scripts, if the right URLs had been requested. Or perhaps the browser was happy to execute JavaScript, it’s just that it failed to fetch the JavaScript, for whatever reason. (Perhaps you put your JS on a CDN, on a different origin, and it’s down.)
In the end, the .no-js approach is far superior to the use of <noscript>.
Of course, if your app breaks because of browser extensions, you should handle errors gracefully, but that goes beyond the no-js classname.
I just posted this since I haven't seen it mentioned and it's fairly useful.
I read that as “you can apply CSS to a <noscript> tag”, which is false. Stuff within it, sure. But the <noscript> tag itself vanishes during document parsing.
I maintain my position: <noscript> is nowhere near as useful as it first appears, and should seldom be used.
I would even suggest that, excluding spiders, user agents that don’t run some or all JavaScript will normally be due to browser extensions. This is a fairly niche area overall, and various extensions are the main factor.
To be clear, the noscript tag "disappears" when javascript is enabled in the browser. When javascript is disabled it behaves like any other tag and can be styled accordingly.
Extension can disable scripts selectively but in that case javascript is still considered enabled for the purposes of the noscript tag.
This is wrong. In case the browser does not have JS (enabled) its a normal element.
I apologise for misleading people.
Web developers don't do graceful degredation anymore.
edit: uBlock Origin shows <noscript> when the entire site's JS is disabled.
Conceptually it's a lot easier to manage if they're fully distinct, or at least if the common bits are explicitly common.
> It must come before the <title> element to avoid faulty characters in the page title.
This isn’t quite true. Rather, any meta element declaraing a charset should occur within the first 1024 bytes, or it may be ignored.
———
Print styles: you might think that putting print styles in a separate file would let the browser not load them unless the user actually seeks to print, but in practice browsers load all stylesheets, even for media queries that will never match. I think this may be for fingerprinting reasons, but I don’t truly know. In the distant past (maybe a decade ago), print stylesheets would block rendering while they loaded in most browsers. No idea whether they still do, but I’d guess (uneducated) that they may be deferred a bit now.
In light of all this, I generally recommend a small @media print { … } block in your existing stylesheet, rather than a separate print stylesheet file.
———
The favicon prefers-color-scheme thing: don’t put too much weight on this, it doesn’t actually do what people are commonly saying it does: there is only a slight correlation between prefers-color-scheme and the colour the favicon is rendered atop. prefers-color-scheme is for content, not chrome. If I recall correctly, Chrome’s incognito mode renders the tab bar dark; and in Firefox the concept of browser theme (light/dark/all kinds of custom) is completely separate from prefers-color-scheme—so I have dark browser chrome but light content.
Understand that the favicon could be being rendered atop anything at all. Any solid colour, any image, anything. Very light and very dark greys are the most common colours for them to be rendered against, but you want to make it so that your favicon is at least not horrifically bad on any background.
Both correct: charset before title element, and charset within first 1024 bytes.
Older browsers would infer charset automatically if not in first 1024 bytes or undefined. So if user had possibility to change the page title (for example: profile name), they could do persistent XSS by having IE infer the title contents as UTF-7, before the actual declaration happens. Sometimes the title or other elements can also be stuffed, so the charset declaration happens after 1024 bytes.
> Older versions of Internet Explorer can be tricked into interpreting the page as UTF-7. This can be used for a cross-site scripting attack as the < and > marks can be encoded as +ADw- and +AD4- in UTF-7, which most validators let through as simple text.
Modern browsers don't fall for this, but this was a huge XSS vector back in the day (for instance, Google was vulnerable to this, and maybe still is, for its users on ancient browsers).
Does it really matter anymore with HTTP2?
https://www.chromestatus.com/feature/6302414934114304
https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYL...
Not sure if HTTP2 push is what you're referring to.
> I totally forgot about print style sheets
You know who else seems to have forgotten about print style sheets, at least for a while? Wikipedia. Or maybe they didn't do anything and it was browser support that got worse for a while, I dunno, I shouldn't be too quick to assign blame to a specific party here.
All I remember is that years ago, if I clicked the "print page" link I would get a nicely styled printable version with minimal markup. It was a great way to get a "light markup" version of the page before browsers had built-in "reader view" tools.
Then for a while it just gave me a terrible¹ webpage version - basically showing the left menu bar and the huge logo when trying to print the page. Now it seems to have print style-sheets again, but with a "no longer supported" warning when used on a screen (not visible when printing though). See and compare:
https://en.wikipedia.org/wiki/CSS
https://en.wikipedia.org/w/index.php?title=CSS&printable=yes
¹ terrible in the context of printing, I'm not hating on the regular webpage here
https://addons.mozilla.org/en-US/firefox/addon/aardvark-duex... (based on https://www.karmatics.com/aardvark/ which is a bookmarklet hence does not work with Content-Security-Policy enabled pages)
It allows to easily and quickly remove stuff from webpages, without opening devtools. Just hover over unwanted element, keep clicking `w` (wider) until you have its whole container, then `r` to remove.
This is what the print style looks on screen on Firefox on my computer: https://ibb.co/QN6Gsjk
Pretty decent if you ask me. Sure, technically its not separate stylesheet in Wikipedias case, but media queries, but the effect is the same.
> Then for a while it just gave me a terrible webpage version - basically showing the left menu bar and the huge logo when trying to print the page.
That is to say: trying to print the page in any way (clicking the "print page" link, using the browser menu) resulted in a webpage-styled output.
document.documentElement.classList.remove('no-js');
document.documentElement.classList.add('js');
with document.documentElement.classList.replace('no-js', 'js');
https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenLis... document.documentElement.className = 'js';I don’t really think the point brought up by the other commenters is an issue. If the `no-js` class is missing, that’s a bug. Allowing it to be missing or present makes the behavior hard to reason about: If there is neither a `js` or `no-js` class, what is the desired behavior?
If the elimination of coupling is desired, maybe we should get rid of the `no-js` class altogether and interpret the absence of a `js` class to indicate no js. I think I like this solution best.
Nowaways I default to "js isn't available" state, and if the script(s) is able to load, then it augments or hydrates the static markup.
I’m gonna be the one to complain about it here. Why are we adhering to a proprietary format by facebook when equivalent meta tags exists. e.g. why is og:description a thing when we have <meta name="description"> and why specify og:title when <title> is literally the only contented tag required by the HTML standard (so all websites are required to have one).
This reminds me of a post from yesterday: “We were promised Strong AI, but instead we got metadata analysis”[1]. And a poor one at that indeed.
Here is an example of a discord server refusing the expand the site description and title on one of my sites[1], just because there is no og:title and og:description (even though I provide both <title> and <meta name="description">).
All I can take from this is either: a) Social media companies are bad at (or don’t care about) implementing common sense features, or b) Facebook is actively and aggressively pushing their own proprietary format over established standards. In either case it is bad.
1: https://forums.online-go.com/t/random-starting-position-flex...
"og:image" has no standard alternative.
The rest are usually not needed. og:description falls back to meta description just fine.
I haven't looked into this method's feasibility in years though. I imagine there are much better ways they protect outbound clicks from their apps these days.
.....
Because facebook/twitter/linkedin have different ways to display information and sometimes what's inside the description (for SEO purposes) is NOT the same as what you want displayed on a social media platform or other outlet for your content!
<title>, <meta name="description" ...> nearly always get used to optimise for Google and not the end user of a social media platform.
<!DOCTYPE html>
<meta charset=utf-8>
<meta name=viewport content="width=device-width,initial-scale=1">
<style>
body{
font:menu;font-size:1.125em;
margin:auto;max-width:40em;
padding:0 0.5em 90vh 0.5em;
}
</style>
I don't use html, head and body tags and I don't close tags that don't need to be closed like p. With this html is almost like markdown.I use this bottom padding, because I like to scroll all the way up and it also is useful if you have low anchors for one to see on top what was supposed to be there.
Excuse my ignorance: what the heck does this achieve?!
https://www.w3schools.com/css/css_rwd_viewport.asp for an example image
https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_m... for more detailed info
This is a cat and mouse game. iOS 14 doesn't respect user-scalable=no or maximum-scale, unfortunately.
What you need to do is this now, if you don't want the web browser to respond to scaling (and as much as the idiots at Apple love their high horses, there are actual use cases for this, including when you are building a webapp or when you are building a web page with your own pinch zoom logic):
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>body { touch-action: pan-x pan-y; }</body>
Basically, Apple tries hard to break HTML5 apps at every new iOS release.When will we ever have HTML5 apps that match native apps? When they actually let HTML5 apps do what native apps do, like multitouch without triggering a default action.
If you want to develop an app, develop an app, not a website. Use Electron or its mobile equivalents if you must.
Also, MS office and Adobe are web apps and far more complex than almost any "real apps" out there. It's completely untrue that web apps are not apps.
> Also, MS office and Adobe are web apps and far more complex than almost any "real apps" out there. It's completely untrue that web apps are not apps.
You can pretend they are until someone takes away your toys. Then, suddenly, your "app" cannot even process its own input. Or access the clipboard. Or do any of the other things that websites just aren't trustworthy enough for.
Yes, there is. The fact the user has installed it.
> Getting rid of js altogether is just throwing away the web to make it something poorly performing and requires sending all data back to the server - so not really a serious option.
Not the web, just webapps. The web will perform better afterwards.
> Browsers only exist to allow interaction with websites, and as such they should follow specs and allow them to be used.
Yes, but those specs have to be sane. Which means even a completely untrusted party – that's what a random website is – cannot abuse them.
> Websites are more important than browsers by definition.
Nonsense, either is useless without the other. Websites are content, browsers define how they're viewed.
Best change made in Safari in a long time. My eyesight is going and unzoomable websites were a serious accessibility issue.
If you give web developers any way to disable zoom they will disable zoom whether it's appropriate or not. With an app that gets human reviewed you can make rules like "this feature can only be used for full-screen games" but not on the web where there's one set of rules for everyone.
There are actual accessibility reasons for wanting to take control of pinch zoom behavior. As long as I'm actually catering to accessibility, if I have to be forced to use the OS pinch zoom to do that it's going to be LESS accessible. The OS pinch zoom only works for text and static 2D images and nothing else. If you try to OS-pinch-zoom a 3D object on a web page, it zooms the whole UI and not the object. That's a major accessibility problem for say a website that offers 3D models.
And no, I don't think "create an app" is the answer as another comment said. I want LESS apps, LESS spyware, and more in-browser, fully-featured, perfect mobile experiences designed in HTML5 because it's MUCH harder to invade privacy with HTML5 than it is with a native app, and if Apple would stop compromising HTML5 features, a huge number of mobile apps can be implemented in it.
Why doesn't it zoom the object along with the rest of the page?
Not zooming in when doing stuff unrelated to intent to zoom, is just not in their interest as determined by Apple.
If a website borks its usability/accessibility you as a user can decide not to use it. If it's a public service or a company there will be for sure pressure for it to conform to whatever accessibility standard is deemed appropriate. Developers in those situations will have to do the work they are hired to do.
Now saying that I should not as an independent developer customise certain behaviour or appearance in a browser (say scrollbars, or many others) to appease that arbitrary accessibility doesn't make sense. If I can't build a certain app (due to arbitrary constraints that have no security implications) then its accessibility is effectively reduced to 0 isn't it?
If I, as an idiot, want to build a website that screen readers won't be able to parse or will spew lines of William Shake-s-pear as image alt tags, isn't that my choice and am I not able already to do so?
As such, if I for instance wanted to write a game in a browser where some of these things are detrimental, and just can't because, no, accessibility, what does that net any one?
This patronising "we know better everything" is sincerely annoying.
It would be nice if web developers could be trusted to only disable zoom when it either does not impact accessibility or when making a website accessible is absolutely not possible. In practice, making an inaccessible website is often more profitable because it's less effort. Also, I've seen a lot of ordinary websites disable zoom for no real reason.
Important websites have to be accessible. So if your website would not be accessible anyway, it not existing may not be a gain for anyone but it isn't a big deal either.
And in many cases, it is better for a website to not exist that for it to be inaccessible: Market forces, your employer, school, university or state can require you to access a website that is not accessible to you. They cannot do that if it does not exist.
I don't want to write an app for it. By your logic websites should be plain text and we should all be learning N frameworks to do things that are way easier to do in a browser, available without having to install black box crap software on our devices.
It makes no sense, since you can do plenty of worse things than disabling zoom, in fact the browser allows a whole range of things that are not in the interest of users and they don't do anything to curb those, so your point is basically moot.
> In practice, making an inaccessible website is often more profitable because it's less effort.
This has no bearing in real accessibility, it's, as plenty of other things, a red herring, since real accessibility is not defined by zooming or changing your scrollbar appearance - as you can confirm by visiting a very large part of the internet.
> And in many cases, it is better for a website to not exist that for it to be inaccessible:
This is like, your opinion. Which besides being as the saying goes, isn't even backed by any rational argument. Just because you keep saying the same words they don't change reality, unless you're Dumbledore, and you're a character in a book, or a movie, and even then, it only changes the story there, not the story outside of it.
All the cases you mention can, and should be dealt with in legal terms - your school, employer, university, or state, are public entities, there can certainly be accessibility guides, references and standards, as there are in a multitude of others things, exactly to regulate that.
Your argument is like saying, that paper should not be used to draw, or do origami, or write in other languages because someone might not understand what it is, or what is contained in it. Of course, that's silly. And when it comes to government, schools, and public entities, according to the type of documents, printed and available in paper, they do have to follow a specific ruleset, without impacting what paper can be used for in other situations.
- Web apps don't require less trust than proper ones. Their developers can use dark patterns, abuse your data, etc.
- Cross-platform frameworks exist
- I have no idea why you think I mind hypertext
> This has no bearing in real accessibility, it's, as plenty of other things, a red herring, since real accessibility is not defined by zooming or changing your scrollbar appearance - as you can confirm by visiting a very large part of the internet.
Are you seriously claiming zooming is not an accessibility feature?
> This is like, your opinion. Which besides being as the saying goes, isn't even backed by any rational argument.
Please stop the flaming.
> All the cases you mention can, and should be dealt with in legal terms - your school, employer, university, or state, are public entities, there can certainly be accessibility guides, references and standards, as there are in a multitude of others things, exactly to regulate that.
Sure. And once there are strict accessibility laws, worldwide, that everyone follows, and all the legacy software has been replaced, we can give developers control over zooming again.
They do, mostly because the browser allows it.
> I have no idea why you think I mind hypertext
Perhaps a better model would be that the web shouldn't be hypertext by default (or can be something else), and instead that hypertext is one of the possible formats for something on the web, along with others - the web would be the "envelope" and not the definition of the content.
If you follow your line of thought to the end, then the conclusion would be that we should be left to pure hypertext.
> Are you seriously claiming zooming is not an accessibility feature?
No, I'm claiming that there's no reason to not allow someone to control the behaviour of certain parts of the browser when browsing a web property of someone else, as long as it doesn't pose a security risk. While at it, the browser could implement white listing of actions, data, and other details that the web property has access to without my consent. If I visit a website for a game and it tells me "this website is going to: - disable zoom - change your scrollbars - change the right click button; check which ones you agree/do you agree" there's no loss of accessibility. And the same for scripts, watching mouse input, text typing, hijacking the back button, showing me popups, etc. Of course that would be technically very challenging to implement.
> Please stop the flaming.
The first rule is if you don't like something done to you, you shouldn't do it to others. Once you do you have to man up.
> Sure. And once there are strict accessibility laws, worldwide, that everyone follows, and all the legacy software has been replaced, we can give developers control over zooming again.
Why do they need to be strict and before-hand?
I omitted the title, but it's a part of the content for me. This way I can use the simplest SSG there is: cat.
[1] https://github.com/Conaclos/origin.html/blob/master/template...
As a default for otherwise-unstyled content, it's not very user-friendly to override the user's default font and size preferences.
The browser lets me decide how I'd like unstyled text to appear. Unless you're explicitly doing typographic design, please don't arbitrarily override my choice.
I would personally not do this if browsers would have sensible defaults, but IMO they don't. Mostly it is a matter of backward compatibility.
Also I'm using font:menu so theoretically the same as your browser is using. Depending on your browser/OS you can change the font for all, not ideal, but doable. Similar to how every browser has different settings for your preferred fonts. But in Firefox for example you can deselect "Allow pages to choose their own fonts, instead of your selections above" and you're done.
I'm saying all this as a person wanting to implement a modern html-only browser to make all those obnoxious stylesheets go away.
If your issue is that many browsers default to a serif font, and you really dislike that, maybe setting font-family:sans-serif would be better? At least that's intended to be suitable for content, rather than UI.
Just blatantly breaking standards like this is not a good idea seen some real howlers from sprint back when I worked on x.400.
And using GTM instead of hand coding every thing is a win
I don't use GTM or GA or almost any JavaScript whatsoever.
https://html.spec.whatwg.org/#optional-tags
There will also be no issue including GTM/GA or other scripts.
<link rel="icon" href="/favicon.ico">
by default if a supported icon isn't found in the markup all browsers search for favicon.ico at the site's root.The same is true for apple touch icon, you can just remove it:
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
I've tested this and it works fine on apple devices. <meta charset="UTF-8">
By default servers add the charset as an http header. So you don't need to declare it in the document — in the case of offline where there are no http headers, the browser works out what encoding to use. And since utf-8 is the only valid charset for HTML5 it should be the default. I've tested this a bit, and it seems to work.Historically, letting the browser guess anything at all has been a disaster. Although IE is all but dead now, there's no guarantee that another browser won't try something similarly reckless in an attempt to be a little too convenient.
For me the answer is yes, if people are using an old netbook on a dialup connection and they save your site locally to save data. That could be a good idea. I'll do some testing though because I think even old IE defaults to utf-8.
The presence of the SVG favicon, with the same rel, may throw the default-finding off. I haven’t tested it, but I would expect various older user agents that don’t support SVG to fall over if you omit the favicon.ico link once you’ve provided the SVG link.
> By default servers add the charset as an http header.
This is not true: it depends entirely on the server configuration. Maybe one serves `content-type: text/html`, maybe another serves `content-type: text/html; charset=utf-8`. The reason people recommend <meta charset="utf-8"> is so that you don’t depend on server configuration that the authors of the HTML commonly can’t control, and which may not always be possible: specifically, what happens if someone saves your HTML page locally?
> And since utf-8 is the only valid charset for HTML5 it shouldn't be the default.
UTF-8 is the only valid charset for HTML now, but that doesn’t mean it’s the only supported charset. See https://html.spec.whatwg.org/#determining-the-character-enco.... The default varies by locale and even user configuration (see the table in step 9). If the default was changed to UTF-8, many non-English old documents would break. Maybe eventually the default will be changed anyway, at least where the short <!doctype html> doctype is used.
I guess that should read most servers? I'm not much of a backend dev, but every default I've seen has included the charset in the headers.
I realize I'm blowing against the wind on this one!
On a site by site basis it seems that you really can get rid of it. I've only tested my own sites offline in various browsers and they work fine without the meta tag.
One example of a site that doesn't use it is YouTube, and I figured that can't be an accident.
For file: URLs, Firefox and, a bit less reliably, Chrome do work out that an HTML file is UTF-8. Safari does not.
> And since utf-8 is the only valid charset for HTML5
Correct.
> it should be the default.
It isn't. See https://hsivonen.fi/utf-8-detection/ for why.
Having <meta charset="UTF-8"> in the boilerplate is good advice.
In actual practice, firefox will try latin encoding if the first few kilobytes are ASCII7 and the document is not indicating its encoding.
They only way to make chromium in dark mode use the CSS color schemes is to add the meta tag:
<meta name="color-scheme" content="dark light">
This is also useful on other browsers: for example, it will make safari choose dark/light UI elements (buttons, dropdowns, etc.) depending on the color-scheme preference.[You can read more about why from smart people on StackOverflow](https://stackoverflow.com/a/8942455/10783165)
[1]: https://docs.microsoft.com/en-us/archive/blogs/ie/living-on-...
Not sure why the the self closing tags became widely used
Source? https://caniuse.com/xhtml says otherwise
> You couldn't do stuff like <div/> and get away with it.
I just tried on both Firefox and Chromium, they parse it properly.
I don't see a reason to mix html and xhtml today. It will only lead to problems. (I.e using self-closing tags and & mismatches in urls)
If you use <div/> in html the browser will just ignore the end / See https://jsfiddle.net/sw8j9fo2/
For a while adhering to the open/close conventions helped use tooling / libraries built around the assumptions for XML in dealing with HTML, maybe up through the late 00s/early 10s.
Any utility gains there faded as HTML5 conventions and libraries became more solid, but I still have a bit of the habit, especially with <img/> & <br/>.
https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.ht...
I was coincidentally checking the same thing yesterday, and yes, '/>' is optional.
(The XML serialisation is still a thing, in various contexts. Serve a document with an XHTML MIME type and the XML parser will be used; or embed HTML in SVG via foreignObject and it’ll be XML serialisation you need. Also note that SVG in HTML invokes… uhh… more XMLy behaviour from the HTML parser, so that the trailing slash does have its XML meaning.)
Some tags such as <meta> and <img> are always considered as a leaf node ("void element"). The HTML parser knows that these tags cannot contain other tags.
Other tags, such as <p> or <li> have various rules saying how to automatically insert a closing tag if it's missing. For example, if you leave out the </li> tags in a list the HTML parser will parse it as if you had closed all the list items.
<ul>
<li>first
</li>second
</ul>
<ul>
<li>first</li>
</li>second</li>
</ul>
For these tags, what ends up happening if you try to use the XML self-closing notation is that the "/>" is ignored and then the missing close tag is inserted at a later point, which may or may not be where you want.If you have something like this:
<div>
<h1>A
<p>B
<img>
<p>C
<h2>D
<p>E
</div>
… it’ll parse to this: <div>
<h1>A
<p>B
<img>
</p><p>C
</p></h1><h2>D
<p>E
</p></h2></div>
See, the headings did get closed eventually, even without their proper closing tags; it just wasn’t where you wanted, either time. (The paragraphs, on the other hand, probably ended where you expected.)Of your example, I think you typed it incorrectly in a couple of places. Here’s what I think you meant to express (plus a third one to make things clearer with the second having a bad trailing slash):
<ul>
<li>first
<li/>second
<li>third
</ul>
… and here’s what that is precisely equivalent to: <ul>
<li>first
</li><li>second
</li><li>third
</li></ul>I think for the most part, it's a pretty reasonable selection of tags. And there's almost no excuse to keep crazy old stuff around these days.
The big non-self-updating X is IE11 which the author addresses separately.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
</head>
<body>
<h1></h1>
</body>
</html>
And according to the file timestamp, have done so since Nov 24 2005. <!doctype html>
<title></title>
<h1></h1>
(My recollection is that the HTML 4.01 Strict DTD doesn’t trigger quirks mode; if that’s correct, then it should be precisely the same, except for whitespace variation and the actual doctype node. Also neither is valid, because the title element can’t be empty.) <!doctype html><html lang=""><meta charset="UTF-8"><title>x</title>If you’re going for shortest valid document at all, <!doctype html> is enough, provided the document exists in a context that makes title optional (e.g. email or <iframe srcdoc>) and that the charset is declared out-of-band.
Your boilerplate lacks all the features of this one...
<html lang=en class=no-js>
This is a feature React lacks.JavaScript is executed differently when it’s a “module script” to when it’s a “classic script” (using the HTML spec terms), so you want a way of preventing old browsers from executing it (whether they’re syntactically compatible or not). Hence type="module", because old browsers won’t execute scripts with the type attribute containing an unknown value.
Once you have that, you commonly want to bifurcate on modules support, so you want a way of saying “don’t execute this if you support modules”. This can be done with feature-detection code, to the effect of “does it support modules? if yes, do nothing; if no, load the code, probably by adding another script tag with the correct src to the document”, but this is inconvenient and causes at least mild inconvenience with security measures like Content-Security-Policy. So the solution was to put another attribute there that new browsers could use as the inverse of type="module": nomodule.
Perhaps it’s a big ol’ sigh, but as is very commonly the case with such sighs, they make a good deal of sense when you understand the reasons and history involved.
<script type="module">
document.documentElement.classList.remove('no-js');
document.documentElement.classList.add('js');
</script>
module has defer semantics by default i.e. it gets executed after the document has finished parsed, and I can't find anything in the WHATWG spec to suggest it's different for inline scriptsMaybe inline scripts ignore module, as they do defer and async
Inline <script> is executed during parsing.
https://html.spec.whatwg.org/multipage/scripting.html#the-sc... gives the full details of the interactions between type, src, defer and async. Inline scripts are normally referred to as script elements where the src attribute is not present.
Doesn't work with the black chrome theme though, it seems. Can't see the icon at all because they gave it no outline.
Browsers don't follow the standard here completely, so you can do:
<a href = /some<!--li=nk<<"&wer' >link</a>
and all that garbage is parsed as is as attribute content until the first space or >. Only thing that terminates attribute value is > or whitespace.
You can also use entity refs in unqoted value.
That means you can use unquoted attribute values for almost anything that doesn't contain whitespace when writing html manually.
Language detection is much easier than synthesis, and one would think that a good synthesizer would devote the 0.1% of their engineering time necessary to have good language detection as well.
The `lang` attribute can be applied to any element, not just the whole document.
We might not need a canonical URL, the favicon declarations are not needed, there's no repo...there's a reason HTML5BP is an industry standard.
There's a reason most of OP's boilerplate is copied and pasted from HTML5BP.
<style>html{visibility: hidden;opacity:0;}</style>
And then put this in your styles.css file: html {
visibility:visible;
opacity:1;
}
Honestly though the amount of meta tags in this boilerplate is ridiculous. What has the web come to? Why can't it use <title> for og:title? Why can't it use the favicon for apple-touch-icon? Why can't it use the URL for the url? Why can't we assume UTF-8 unless told otherwise?"Why can't we assume UTF-8 unless told otherwise?"
And this I really do not understand either. I lost hours to restore data, that got lost in conversion from various text encoding formats, discovered too late.
Because the <title> is often something like "My Content | The Example Blog", which is a redundant information on social media cards so you set og:title to "My Content" only.
> Why can't it use the favicon for apple-touch-icon?
Because the favicon usually is a 32x32 icon that is small and only seen in the tab of the browser, whereas the apple-touch-icon is physically huge, and so requires more resolution.
> Why can't it use the URL for the url?
I assume you're talking about the canonical link tag? This is to prevent SEO penalties - specify a canonical link and Google will prefer your site as origin for the content over spammers that don't bother setting the tag, or in case you run an old-school site with dedicated mobile and desktop sites (see https://developers.google.com/search/docs/advanced/crawling/...).
> Why can't we assume UTF-8 unless told otherwise?
Historical baggage, mostly - the default charset for old content unless specified was either US-ASCII or its superset ISO-8859-1/latin1 (the HTTP/1.0 spec defaulted to US-ASCII, see https://tools.ietf.org/html/rfc1945 section 3.4 and the HTTP/1.1 spec, section 3.7.1, https://www.ietf.org/rfc/rfc2616.txt that defaults to ISO-8859-1). And there is a lot of old content that would break if this default assumption would change.
If you call 2019 history already...
https://techcommunity.microsoft.com/t5/windows-10/windows-10...
You can have multiple rel=icon elements with different resolutions or even scalable ones. Also, browser tabs are not the only place where the favicon is used - and definitely not the original one.
Because you can have multiple URLs for the same content and you need a way to say "by the way if you want to link to this page here's the proper URL"
For example, if you have example.com/blog/foo, it's possible that m.example.com/blog/foo, example.com/blog/foo/, example.com/index.php?path=/blog/foo, example.com/index.php?p=1234, example.com/blog/foo?textonly=1 etc etc all point to the same blog post and in many cases you simply can't set up a redirect because the URL is valid.
Most of the pages I make are unique and supplying these values twice is simply redundant. My only conclusion is that scrapers are stupid and developers are too laze to fix it (which ironically casts the work on other developers as we now need to supply these redundant values).
At this point I think it's more about unequal power than it has anything to do with developer laziness. Facebook and Twitter can tell others to add whatever stupid tags they demand, and people will comply. They can even call it a standard, and people will readily acknowledge it as such. Why change the status quo when you have the upper hand?
They do fall back to <title> and <meta name="description">. At least Facebook does.
You can test it here (requires facebook login). It works though they complain about the missing tags. https://developers.facebook.com/tools/debug/
On the rest: I mostly agree.
<title> versus og:title is commonly stupid, especially because consumers will tend to fall back to the <title> tag anyway (though in theory they should differ, with <title> normally including the site name, but og:title not supposed to); og:url and rel=canonical are even more stupid, because consumers will fall back to using the actual URL, so their only purpose is cases where the content is actually found at multiple URLs. (“But og:title and og:url are mandatory for OpenGraph validity!” you say? Please, you didn’t even put the prefix="og: https://ogp.me/ns#" attribute on the root element. No one does. No one cares. And I don’t think anyone cares for at least og:title and og:url either, though <meta property=og:description> versus <meta name=description> is uglier, and you can’t even merge the two or Twitter ignores the thing.)
Why can’t we assume UTF-8 unless told otherwise? Historical reasons, mostly. The web is an old place. Rejoice that everything new is done purely in UTF-8, and be comforted that even some of the older things are slowly shifted to a UTF-8 default over time, as the impacts of doing so become smaller.
The Apple icons are a more complicated historical mess. Be glad it’s down to only one stupid extra tag now, rather than a dozen or so, for each of their different device sizes. The time has come when they could fairly reasonably merge it back into icon, since they’ve given up on all of their fancy appearance of their icons.
Most content can be retrieved using multiple URLs - for example this comment section is available at both https://news.ycombinator.com/item?id=26952557 and https://news.ycombinator.com/item?id=26952557&blah as well as infinite other variants. Even if you only actively link to one version, you can't be sure no one else will fuck it up so rel="canonical" is useful. og:url should just default to that though (no idea if it does).
https://techcommunity.microsoft.com/t5/windows-10/windows-10...
Mine is truly minimal: https://github.com/TimDaub/mynimal-html5-boilerplate
<!doctype html>
<title>Your website: title</title>
<h1>Title of your site</h1>
<p>
Here begins the text of this page.
This is a complete, conformant, html5 document. Markdown is unnecessary nowadays.Exactly! I personally hate Markdown. I can never remember how many asterisks is bold, italic, or whether images are [!img(src)] or !(img)(src) or  or [link](src!) or some other nonsense.
HTML is much more consistent, limiting yourself to a subset of HTML keeps things very readable, and it's super easy to slap a stylesheet on the top and make it come to life, and change that stylesheet at any time.
Links are [](), but I do mess that up sometimes as well.
Markdown is not inconsistent though, and I find it very readable.
I think something ate one of your *s. One star or underscore for italic; two stars or underscores for bold.
> Links are [](), but I do mess that up sometimes as well.
If you use the "remote ref" style[1], links are `[text][ref]` which is much easier (I remember the order as "this [text] points to that [ref]").
[1] https://www.markdownguide.org/basic-syntax/#reference-style-...
That's because HN supports stripped version of Markdown and supports italic with one *, but not bold with **. You have to escape it with \.
I find HTML far more writeable than Markdown, however, as all things have a consistent syntax.
# You website: title
## Title of your site
Here begins the text of this page
I do think it's easier to type.I agree, but it's only marginally easier to type.
But the markdown is not the final product, it still needs to be converted to html using a "static site generator" or some other thing that breaks every couple of years. I had my static site break due to jekyll shenanigans four times in the last few years, and then I decided to move the whole thing to plain html, and replace jekyll and its myriad of unused and fragile dependencies with a three-line shell script that calls "cat". Moreover, markdown is confusing to use for basic stuff like links, images (see the sibling comment), and even enumerated lists [0].
[0] https://stackoverflow.com/questions/12145232/create-an-autom...
every dialect of markdown has an infuriatingly different way of doing basic things that totally breaks your soul if you use a handful of them at the same time.
EDIT:the example you wrote is not exactly the same thing as mine, is it? It seems like it would convert to H1 and H2 headings and both would be displayed in the body.
- When I'm in the flow, I really don't want to think about the structure of my text. The ms required for the tag insertion breaks that.
- Unless you very disciplined with your HTML use, it's hard to get back structure from you HTML doc. You have to limit yourself to the subset you would get from markdown.
I'm experimenting with asciidoc now, let's see if it's working.
Not sure but guess for me the latter, what about you?
The main inconvenience of writing plain html is the need for <p> tags. They really do break the flow! It would be so much better if a blank line inserted them implicitly. This is indeed the killer feature of markdown and TeX.
Never tried hugo, but it surely must be cleaner than jekyll. As a matter of policy I prefer to install tools packaged by my distribution. For debian, the jekyll package went through several "engines" and whatnot along the years, and each change broke the build. For some reason it even needed particular python versions, even if it is written in ruby. A complete nightmare. I honestly lost faith in static site generators after the experience with jekyll. Even if hugo is saner, it is still amenable to breaking as its debian package evolves, and I don't want to deal with that.
I do care about breakage of my C, C++ and Fortran programs, and I would be very surprised if updating gcc broke their build (unless using -Werror). Why can't static site generators, which are arguably much simpler than compilers, have the basic property of not breaking sites?
This is a huge plus for me. Any list with more a dozen of entries and it would be tiresome to have to fix that. Also I can move the lines around freely without weird formatting issues.
Links are okay in my opinion, images are just a bunch of crap. To make an image clickable you'd have to do an image within a link, something like:
[](url)
> every dialect of markdown has an infuriatingly different way of doing basic things that totally breaks your soul if you use a handful of them at the same time.Completely agree there. Extensions of Markdown are really annoying, but I guess that's what happens when "true" Markdown wasn't updated since 2004.
Also if you want to fully commit to JS frameworks, you can. Some frameworks support MDX, which has full support for JSX tags. You can include react components right next to your text.
HTML has two ways to make things bold: b and strong. But only one way to make a toplevel heading, h1.
Markdown has one way to make things bold: ** **, but two ways to make a toplevel heading: # or ======
Other users have commented that Markdown in the wild is now little more than an alternative syntax for HTML, with scripts and other tags freely embeddable.
Moreover, HTML is basically HTML: we used to have problems with browser compatibility, but most of those are in the land of CSS and Javascript now. Whereas Markdown can be found in different flavors. Aside from the burden on the author to know what flavor they are writing, it limits the reusability of documents. Consider a git repo that has a Github-flavored README.md file written for github, but it is also shown as part of the package documentation in a language specific library repository that shows the same README.md file using a simpler flavor of Markdown. The basic tags probably all work fine, but the broken CI badges will perhaps make it frustrating to read.
HTML and Markdown both began with the best of intents as declarative document markup schemes. But because it is much harder to design a declarative programmer interface than an imperative one, both have accreted junk.
> Markdown in the wild is now little more than an alternative syntax for HTML, with scripts and other tags freely embeddable
HTML is not in the MD spec. We use a WYSIWYG MD editor so it's not an issue.
Well...
You expect people to paste the MIT license into their website source in order to use your "minimal" headers?