Those HTML attributes you never use
smashingmagazine.com
smashingmagazine.com
My favourite was relational links such as
<link rel='first' href='/de' title='Homepage' />
<link rel='prev' href='/some/bunnies.php' title='Previous Page about bunnies' />
<link rel='next' href='/some/cats.php' title='Next page about cats' />
<link rel="copyright" href="/de/impressum.php" title="Impressum">
<link rel="alternate" href="/gr/samepage.php" hreflang="gr" title="Page name in greek">
Opera was the only browser which had a toolbar with these relational links. This was around mid-2000. Unfortunately, this toolbar never survived or got taken over by other browsers.Some relations survived (such as rel="search" for custom search pages), some got killed-by-ecosystem (such as RSS).
<input type="slider" min="0" max="100" step="10" name="foo">
<input type="toggle" value="true" name="bar">And a "toggle" input is just a checkbox.
checkbox -- not a toggle, requires incredible pecking accuracy on mobile, non-hummingbirds cannot use
At least that part is easily solved: Assign a label to the checkbox, label is tap-able. nice large target.
Styling it to look like a native toggle control is harder.
It seems we are going to get more good ideas in unfinished form?
The definition of a range is: "the area of variation between upper and lower limits on a particular scale." Why would the user only get to configure 1 of the 2? The definition of a slider is: a knob or lever that is moved horizontally or vertically to control a variable, such as the volume of a radio.
enterkeyhint="next" conceptually a great idea. Sadly it doesn't do anything? I wanted an attribute that makes the button go to the "next field".
Easily fixed by every developer individually a million+ times deep into the future.
What's wrong with the navigation controls provided by the browser for this purpose?
We had a good thing going there. It does what it says on the tin. Its how I (and everyone else) like things. A stop button makes it stop. Scissors are to cut. The little floppy disk is to save. A play button makes it play. etc
It seems so fundamental? How could anyone get this wrong? The user wants working buttons on their interface. Buttons that behave the way they expect.
I think no one wants an enter key that looks like a "next" button. In case I'm mistaken about that they could simply add a different value domstring.
>'enter' typically indicating inserting a new line.
I have to inserts a new line at the cursor?
>'done' typically meaning there is nothing more to input and the input method editor (IME) will be closed.
I have to close it?
>'go' typically meaning to take the user to the target of the text they typed.
I have to submit the form?
>'next' typically taking the user to the next field that will accept text.
I have to move the cursor to the next field?
>'previous' typically taking the user to the previous field that will accept text.
I have to move the cursor to the previous field?
>'search' typically taking the user to the results of searching for the text they have typed.
I have to submit the form?
>'send' typically delivering the text to its target.
I have to submit the form?
Maybe I'm missing something (I hope so)
I don't quite get what you mean here.
It means that if they ever want to introduce a real range selector it will have to get a different name.
It also means that if you search google for a range selector you are no longer able to find any of them. If a native one is ever introduced you wont be able to find it searching for range selector.
Also quite silly is that if you need both in your form you cant use this build in one as it will look different from your custom creation.
And it makes it harder to reason about forms. In the previous sentence I wanted to write "...need both a slider and a range selector" but that seems inaccurate/confusing.
Frefox had it to, it's this famous bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=2800 opened 24 years ago.
They had a toolbar for it for a while, and I used it for forums and search results. And then they got rid of the toolbar, and the rel link because used only for search engines.
As of 2019, Bing was looking at those links for URL discovery. https://twitter.com/CoperniX/status/1108790528773021696
I wrote something like that for my homepage, although as I only needed to switch between two styles and I'm not a front-end person, I didn't bother with an actual selection drop-down and just wrote a toggle that cycles through all alternate stylesheets one at a time.
I just wish it got a higher priority by browsers to have good built-ins.
I attribute this advice to Æleen Frisch; albeit without pulling my very dog-eared copy from the stacks, I recall that words to similar effect can be found in the epochal Essential System Administration (2002), possibly in the form of reading every manpage in your local Unix base system.
Each row can be its own form and you still end up with valid html.
The button's name (optionally also its description) and to some degree its position in the DOM order (what heading and/or other form elements precedes it) needs to be sufficient to convey what will happen when it's used.
This can also be done by the webserver with Content-Disposition. [1]
But it's cool, I didn't know this could be done with HTML, it offers a lot of possibilities.
[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Co...
There is no straightforward way[0] for you to gracefully handle an error, which is quite an oversight once you factor in that network isn’t always reliable.
Having used it at first, I switched to server-side logic where I return data with Content-Disposition header if everything went well or redirect the user to show a proper error message in case of a problem.
[0] I imagine this could be worked around with some JS-based preflight or other trickery—which sounds like a suitable solution only if you have no control over the headers returned for some reason.
(Correction: per spec, the domain does enter the picture in that cross-domain <a download> is not supposed to work at all without Content-Disposition response header; that’s slightly different matter to what’s discussed.)
Something to watch out for.
Though that is at least consistent with other download options like right-click/save-link-as, so is probably not incorrect behaviour.
I’m OK with “Save as” (“Download linked file”, etc.) behaving as it does: it is more or less intuitively clear that with it we sort of “cheat” and use browser’s semi-hidden feature to interact with a website in ways not necessarily intended by its engineers. With the download attribute, however, any confusing outcome falls squarely on me, the developer, so I’d rather stick with plain links and response headers as a mechanism I have more control over.
There may be some workarounds to make download behave adequately in case of an error, such as having your server behave in some way that causes browser’s fetch sequence to fail with a low-level error. Unless I’m missing something, it seems like proper network error is the only condition under which download can actually fail, and I don’t think a typical web framework setup is equipped to intentionally cause that to happen. I doubt it’s worth the bother—if you have control over the server then why not drop the attribute and just return the appropriate headers.
As I had no control over the frontend itself, I configured the reverse proxy so that for requests to download endpoints, all error responses would instantly close the connection to the client.
Your post makes me think that I could generalize this so that any error to an explicit download would close the connection at the network level. It would be quite tricky to be able to distinguish between implicit and explicit downloads, but I think that if the frontend, backend and reverse proxy coordinate well together, it can be done without introducing other problems.
Of course, it's a big hack that's not worth the bother.
1. Use JS, in which case one can handle errors and otherwise be involved in the request / response process. However, if you wish to offer a "download" funciton, this necessitates downloading all the data into JS memory before offering it to the user.
2. Use form-posting with `Content-Disposition`. One can no longer be involved with the request and response. And any response which does not have `Content-Disposition` will result in the browser redirecting. However, the user will be able to directly stream the download without your page being involved beyond initiating the request.
Since the data downloads are gigabytes in our case, we opted for (2). But I would also love to hear if I'm wrong about this trade-off.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#...
Maybe just me.
Which kind of illustrates why a lot of these things are not well-known. Why do something that that works on Firefox but not Chrome/Edge or on Safari/Firefox but not Chrome, etc? Specs are great, but near universal, reliably similar implementation is key.
In a lot of cases it means you have to build edge case UX. I'd rather lean on UX that's mostly under my control and not at the whim of browser adoption.
I did at least find some blink discussion on it: https://groups.google.com/a/chromium.org/g/blink-dev/c/Hfe5x...
This site suggests that enterkeyhint is supported on Chrome: https://caniuse.com/mdn-html_global_attributes_enterkeyhint
My own testing also shows that it works. Using the "search" value of the attribute, I was able to change the enter button into a magnifying glass.
[1]: https://standardebooks.org/manual/1.6.3/single-page#5.8
I love the <download> attribute, it's a quick way to use the default file download mechanisms without having to bother the user with opening a link or prompting. I realize there is the potential for abuse, but if you're careful, it's wonderful.
Native lazy loading support is coming to a bunch of things in the near future, if it's not there already, so this one is living on borrowed time.
If you've ever tried to implement CSP on a site, crossorigin and integrity should be famiilar - alas, CSP is hard, but you already knew that didn't you :)
Writing "<download>", with the word in angle brackets, makes it look like an element but it's not, download is an element attribute.
I am aware of the distinction, I only used that way b/c HN doesn't really have a good way to indicate code without multiple spaces or just blindly using the ` character which is...not great.
How to use <cite> is often misunderstood. Many think it can be used to identify the author of a quotation but it should only be used to name the work a quotation is from. Standard Ebook placed it inside the <blockquote> but I've also seen it placed after <blockquote>, I don't know whether both are considered correct or if it's a point of disagreement; to me, <blockquote> should contain only the quoted material itself but I understand the appeal of having the quote and its source be neatly contained within one semantic element.
Using the Markdown convention of putting backticks around `code` may not be great but at least it won't be confused for the wrong actual code.
I believe our use of <cite> predates the modern definition of its use, and in any case it's so infrequently found in a web context that I don't think there's much agreement about how it should be used anyway. (For example MDN says the work title must be in <cite>, but at SE we often only include an author name, like <cite>--Shakespeare</cite>.)
[0] https://en.wikipedia.org/wiki/HTML5#W3C_and_WHATWG_conflict
I recall in a (lost) blog theme I had at one point in time I'd scrounged a nice bit of CSS to add cite attributes visibly appended to blockquote and q elements. Exposing it to the user is possible in just pure CSS, but it is a bit of a shame that browsers didn't style it by default so many people didn't learn it was a thing.
<q cite="https://www.w3.org/Consortium/">To lead the
World Wide Web to its full potential by developing protocols and
guidelines that ensure long-term growth for the Web</q>
q::after {
content: attr(cite);
}
That will show the source URL for a quote but it's not very useful, the URL isn't clickable (unless you wrap the whole <q> in a link), it's not even selectable text.Not selectable is still a bit annoying in that case, but Author Names don't need to be clickable links and the point comes across.
It used to be the case that the values of `content` properties weren't read by screen readers so this technique would mean the information was solely conveyed visually, that blind screen reader users wouldn't get it, but screen readers have been reading `content` properties for a while.
In any case, if the citation is important information to convey, it should probably exist at a text node in the document, not as metadata that gets pulled out and displayed by the styling.
[0] https://html.spec.whatwg.org/multipage/indices.html#attribut...
blockquote::after, q::after {
content: " - " attr(cite);
display: block;
font-style: italic;
}
Should do the trick nicely.In the nine years since that post, I have not once used it in a real project.
Yeah, I had the same cynical assumption before reading.
All in all, I can't remember coming across a deprecated HTML feature that I needed and didn't already have a better alternative.
Furthermore I think you can still use this stuff. Apache and Lighttpd are still perfectly fine web servers depending on the use case. Also nginx supports server-side includes and fastCGI.
What is taking so long? /s
(Only a bit of sarcasm there, I actually would like to know...)
None of the attributes in the article are deprecated, some are underimplemented (alternative stylesheets).
The MDN page about <blink> has example CSS to make the element blink again. If you wanted to make speed variants, you could use CSS selectors that set different durations based on a data attribute and its value:
blink {
animation: 2s linear infinite condemned_blink_effect;
}
blink[data-speed: fast] { animation-duration: 1s }
blink[data-speed: slow] { animation-duration: 4s }Who's using (or even heard of) <abbr> and <dfn> without `title`? I kinda thought that was what made them most useful, providing the full unabbreviated version for example.
That said, opening links in a new tab/window is the less-breaky approach these days, since every page that the clicks came from is a mess of infinite scroll and reactive components and all sorts of other state that gets lost by clicking to another page and trying to go back.
not sure about <dfn> without a title though.
Also, it allows you to ensure that if you have a button that says 'download', it will actually download the file instead of having it replace the application---the principle of least surprise.
Target _blank keeps the title of your page on the screen and clickable.
That's before the accessibility concerns, users don't expect pop-ups anymore and find this confusing and difficult to navigate.
I use it when setting acronyms in small caps. Their spelling can look like screaming otherwise.
Or imagine web browsers providing upload progress ;)
But well, designers like to give all that their custom design.
https://developer.mozilla.org/en-US/docs/Web/API/FormData
Uhh, JSON would have been nice I guess?
When I got frustrated with the user needing to be able to re-edit a form with waaay to many fields and the option to add more fields of various exotic types. I wrote a hilarious hack where I just went over the input elements and elm.setAttribute("value", elm.value). Then I rip out the entire form innerHTML, POST it and store it in the database. Want to edit it again? Here you go! When displaying the content wrap the form in: <fieldset disabled="disabled"> and add some border:0;color:black
For such a terrible idea it looked remarkably clean.
Maybe keyboards will have a few lcd keys, or for cost cutting a colored led keys to match these kind of hints
There are enormous numbers of keyboards with per-key RGB lighting available. And the host OS can control them (right now my keyboard is lighting up with the music)
> non tech savvy people
Tech, in many situations that intersect with non-tech people, is now some form of touchscreen with an onscreen keyboard.
Exceptions are corporate HR departments, whose hardware, software, and flow seem to ignore the fact that phones are the primary Internet device now, not PCs like it was in the 90s.
If your actual job requires you to use a PC, you probably simply just need to learn to use a keyboard because the apps you are using are going to be complex to, e.g. Office suite, etc.
it's not the keyboard, it's the meaning 'RET' has for a particular form. It can be a per field 'accept then go next' it can be 'validate the local group', 'validate the main form and submit it back', 'accept a partial choice but don't change focus'. That's why the hint is brilliant, it removes confusion.
Also people who need this knowledge are never given good tutors. It's mostly "deal with it, and be fast or else.."
https://en.wikipedia.org/wiki/Optimus_Maximus_keyboard
Apple has a patent on the concept; maybe there’s still one in our future:
Also, it's right in front of your eyes, so it's clear when it says something else. Your computer keyboard isn't, and people don't usually look at the enter key before hitting it (even hunt-and-peck typers should have the enter key committed to muscle memory). Forcing people to look down at their keyboards before hitting enter would make ergonomics worse, not better.
I think this is one reason people quickly move on to using popover libraries for simple popovers.
This is an interesting one, although I find native lazy-loading with the "loading"-attribute more interesting: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/im...
(The menu item was actually mentioned in the article linked here.)
I found some posts from from 2004 which does refer to the icon:
https://fantasai.inkedblade.net/weblog/2004/firefox-altss/
https://web.archive.org/web/20041103090311/http://weblogs.mo...
I wish I could find some screenshots!
w3.org used to feature this, you could view the website in any of the stylesheets they offered, which were a bunch (about 5-10 if I recall correctly).
This is perhaps internally consistent.
Well it depends what you mean by entirely new, the syntax is that of a stylesheet. If we didn't have external stylesheets then maybe it wouldn't make sense to have a style attribute? but we do, so there seems to be some some logic for why we have an attribute that mimics it.
Not really sure if this is a worthwhile conversation to be honest as you seem to want this to be much more antognistic than it needs to be.
Good luck in your quest.
You certainly can do things to overload attributes and do what you're suggesting (in a sort of hackish way), and you wouldn't necessarily be wrong in doing so if that's your preference. Many people just don't like that.
One of the great things about separating styles out of HTML is that they can be contained in files and included separately. With poor connectivity, ideally, it's beneficial to keep the main page source to be as slim as possible so that it can still be downloaded and read even if the styling hasn't yet finished downloading. That's not nearly as relevant anymore, but it would not be surprising if keeping pages lean was a motivator in moving away from putting more stuff in HTML.
I think a lot of confusion from HTML being used for UIs vs hypertext documents. It’s a natural evolved mess still balancing the two.
But style should apply to the applied representation, while HTML should represent the intent of the content. The line is fuzzy, and HTML/CSS has a bad history of what falls where.
The cool thing with browsers is that we can bake in style to support multiple representations at once: monitor, mobile, printer, etc. Using the style attribute directly is mostly a side effect of only targeting the browser. Although your example of relative units is more ambiguous. Using a proper tag to represent the intent or falling back to a class where HTML lacks one would be preferable.
I think the separation makes more sense if you’ve used other document systems. SGML or XML DocBook, LaTeX, ROFF, etc.
For the last, if I use the man or mandoc module, all the man page norms are there for me and I’m just plugging in the content with the right macros.
W/o, I’m manually flipping registers all over the place.
But I’ve never hear of a roff or LaTeX UI, so…
If any CSS property was also an HTML attribute, any addition to either spec would have to make sure it wouldn’t conflict. One example is the `content` HTML attribute and CSS property. They serve different purposes and have a completely different syntax.
<meta name="description" content="Cool stuff”>
and .css::before {
content: url(image.bmp)
}Sorry but I think you guys/gals don't get it - the question is why do we need two item-value syntaxes. Like, HTML has 'bgcolor=black' as markup attribute, and owing to SGML, the effective value for that attribute can be defaulted, inherited, and assigned in a context-dependent way. Those mechanisms aren't directly part of HTML because they don't need to be when it's understood that HTML as an SGML application can of course make use of all the authoring mechanism SGML has. But then comes CSS and defines an entirely new syntax that's almost the same (eg. "background: #000"). How is that helpful?
To say it in another way: let's assume we want web pages in 3D space, and yes I know z-index and CSS parallax effect are a thing so bear with me. Following the CSS logic, we should tunnel a background depth/z coordinate via CSS-in-HTML, like
<p style="background-image: url(bla); 3d-props: 'z is -100angstrom, depth-of-field is 123deg'">
where I deliberately have chosen ad-hoc characters for the item/value separator and multiple-properties separator to make the point.You know, having a common meta syntax for elements/attributes is the entire point of SGML as a text format after all ;)
To answer pragmatically:
- don’t use the style attribute
- you could use XLST, which is style (and more) that uses the same ML
- are you suggesting that CSS and HTML should have the same style? <a style=“color=\”red\””>? I don’t know how that’s better.
Maybe you’re still missing some lecturing: HTML is content and CSS is style. What you’re saying about 3D context would be specified in CSS, in a separate file, so your CSS-in-HTML readability argument (I guess that’s your argument? Who knows) falls pretty flat.
It’s almost the same as complaining that JS doesn’t have the same format as HTML while it totally could, but instead we have JS-in-HTML. Oh how unfair life is.
As far as I can see, you’re just trolling, so thanks for the laughs.
Signed,
<a onclick="this.style.background='url(<svg title=\"🖕\"><rect fill=\"blue\"/></svg>)'">"are you suggesting that CSS and HTML should have the same style? <a style=“color=\”red\””>?"
Probably more like <a css-color="red"> - or alternatively: <a id=xxx> and in an css file: .xxx { href: "http..." }
I also think that you need to chill.
Ironically XML allowed namespaces so css:color="red" could have totally been a thing. However CSS came out to separate content from style, so doing that wouldn’t have made much sense. I wouldn’t be surprised if the style attribute was added later.
Edit: wow I was right:
> HTML 3.0 supports style sheets via the use of the LINK element [1]
> HTML 4.0 adds new hooks for style sheets, which suggest how a document is presented. The new ID, CLASS, and STYLE attributes [2]
[1]: https://www.w3.org/MarkUp/html3/intro.html
[2]: https://www2.cs.sfu.ca/~ggbaker/reference/wdghtml401/new.htm...
This is my first post in this thread... And no, it is not moving any goalpost.
"However CSS came out to separate content from style, so doing that wouldn’t have made much sense"
The first is true, but it does not imply the second.
No thanks... I don't want to learn about your privacy settings? It's okay... store everything?
Really needs a course correct to find a better balance...
“Legitimate interest” is proof that “your privacy is valuable to us” just means “we are happy to shatter your privacy in exchange for some value”. Every “legitimate interest” box basically says “we see your preference, but fuck you and your preferences”.
It’s not perfect, but it helps.