Wikipedia:Reference desk/Archives/Computing/2021 April 27

= April 27 =

Identifying a user agent using HTML and/or CSS
Is there a means by which the user agent (i.e. browser) may be identified by means of HTML elements and/or CSS declarations? I've got a rough idea, using this stylesheet:  with this HTML:   Are there any identifiers which one user agent defines or recognises, but others don't? -- Red rose64 &#x1f339; (talk) 14:04, 27 April 2021 (UTC)


 * In JavaScript, you can use the following property to ask the browser for its the user agent.
 * I don't believe it's possible to detect it using CSS alone, and usually, webpages shouldn't attempt to render differently depending on the user agent. If you want to know whether a browser supports a particular feature, you should do this using CSS feature queries, like the following:  Hope this answer helps, RoxySaunders (talk · contribs) 00:13, 28 April 2021 (UTC)
 * Thanks, but I can't write Javascript, and don't intend to try. I did once get a book on Javascript from the library, and tried example 1 - display a button titled "Submit" which if clicked, would display "Hello, world". Clicking it crashed not only my browser but the whole machine, and I lost the word doc that I had open in another window. Not a good sales pitch for javascript if it can cause that much damage. -- Red rose64 &#x1f339; (talk) 09:14, 29 April 2021 (UTC)
 * This sounds like an incredibly exceptional event, I doubt it'd ever happen again. —moonythedwarf 13:06, 29 April 2021 (UTC)
 * It's just as well. Every time a web server tries to recognize details of a particular browser and adjust its behavior in some way, poor Jon Postel spins in his grave. —Steve Summit (talk) 22:17, 29 April 2021 (UTC)