1194 points · by adrian_mrd · 5y ago · 276 comments
<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.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.
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.
<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>.
edit: uBlock Origin shows <noscript> when the entire site's JS is disabled.
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.
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!
> [not] for a decade
Agreed, probably longer. How old is Modernizr?
Who asked?
> 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...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.
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.
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.
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.
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.
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.
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
[1] https://github.com/Conaclos/origin.html/blob/master/template...
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.
Best change made in Safari in a long time. My eyesight is going and unzoomable websites were a serious accessibility issue.
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.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.
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.
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-...
(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>Not sure why the the self closing tags became widely used
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/>.
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.
https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.ht...
I was coincidentally checking the same thing yesterday, and yes, '/>' is optional.
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.
<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?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).
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/
https://techcommunity.microsoft.com/t5/windows-10/windows-10...
"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.
Mine is truly minimal: https://github.com/TimDaub/mynimal-html5-boilerplate
You expect people to paste the MIT license into their website source in order to use your "minimal" headers?
<!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.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.
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.
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.
# 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.
Well...