How does `#:~:text=` in URL works to highlight text? - html

TL;DR
How/why are some browsers able to search and highlight text in the HTML body which is followed by #:~:text= in the URL?
Explanation
One day I was searching for something on Google, which lead me to Quora's result. I observed that 2 sentences were highlighted in yellow, which were part of URL after the aforementioned parameter. I thought this would be Quora's feature for SEO or something, however, also found this on Linkedin, and Medium, and so on.
I'd like to know:
What is this highlighting called? Why/how does it work?
This seems to be browser-specific. What kind of browsers support this?
It seems to work on Chrome and Edge; but not on Firefox, Safari, and IE.
Does a frontend programmer need to incorporate something in the code to have search engines highlight content on their web-pages? (Based on the assumption that search engines actually appends the relevant string predicted by user's query)

The highlighting is called Text Fragments. Its a new feature that was recently added to Chrome 80. It works by specifying a text snippet in the URL hash.
Yes it is browser specific.
No, the experience that you get when clicking on a link from Google's search results is part of Featured Snippets which are algorithmically determined. There is nothing you can incorporate into your code to prompt search engines to highlight text on your page.
There is no markup needed by webmasters. This happens automatically,
using Scroll To Text for HTML pages
https://chromestatus.com/feature/4733392803332096. See also more
background here: https://support.google.com/webmasters/answer/6229325
Sources:
https://web.dev/text-fragments/
https://www.theverge.com/2020/6/4/21280115/google-search-engine-yellow-highlight-featured-snippet-anchor-text
https://www.theverge.com/2020/6/18/21295300/google-link-to-text-fragment-chrome-extension-chromium-highlight-scroll-down
https://searchengineland.com/google-launches-featured-snippet-to-web-page-content-highlight-feature-335511
https://blog.chromium.org/2019/12/chrome-80-content-indexing-es-modules.html

While text fragments is natively implemented only in latest Google Chrome (and the latest versions of Chromium-based browsers, such as the new Microsoft Edge), there is a browser extension/add-on that seems to enable it on Firefox and Safari: https://github.com/GoogleChromeLabs/link-to-text-fragment
It appears to use #ref-for-fragment-directive:~:text= and additional arguments (instead of just simple #:~:text=).
Firefox: https://addons.mozilla.org/firefox/addon/link-to-text-fragment/
Safari: https://apps.apple.com/app/link-to-text-fragment/id1532224396
Curiously enough, the extension has also been made available for Chrome and Edge too (!).
.
UPDATE: I'm testing it on Firefox Developer Edition, and it doesn't work for me.

Related

Chrome is truncating part of my pdf address

We have a catalog on our college website.
It may be found here:
https://www.southark.edu/admissions/resources/course-catalog
The links going down the left side of the page point to specific pages within the catalog.
For example:
https://www.southark.edu/images/catalogs/2021-2022/2021-2022_SouthArk_Catalog_FINAL.pdf#page=100
But when clicked, Chrome truncates the last portion of the url (in this case, #page=100), and it displays the first page of the catalog, not the intended page.
This happens in Chrome, but not Firefox.
It has worked in Chrome for years, but now it does not.
Any idea why Chrome is doing this and what kind of workaround I might be able to do?
P.S. I just tested it in Safari on my iPhone and it is doing it on there as well.
Thanks,
Charley
I discovered that it is due to the Chrome PDF extension. If I turn it off, it operates as it should.

How to find out which favicon a browser actually uses

I have a new website with a set of favicon images auto generated from a source file using Real Favicon Generator, and there are:
9 Apple favicons
1 Android favicon
3 named favicons
1 Safari pinned SVG
1 json manifest
1 set of Microsoft tile image/colour
Obviously most of these can be placed for their respective vendors - Apple, Microsoft tiles, etc.
I have an issue in that running the website on Firefox, I want the favicon it uses to change but I do not know which one it actually uses?
I have read this question but the stated answer on here is incorrect and
Firefox and Safari will use the favicon that comes last.
is no longer true.
Obviously it's a time consuming repetition to go through ~15 images to find the one that gets changed on one browser, and I actually found that Firefox 42 selects the 96x96 dimension favicon, rather than the last one presented.
Question:
Is there a way [aside from trial and error] to load a page and then find a declaration in the browser defining which image from the HTML head is used as the page favicon in that browser?
Additional Information:
There is an incomplete reference list here. However, this misses out various versions and various OS, and I can only assume these details where found from trial and error.
While this is useful, the various links and solutions on that question give a single URL result for an automated process, such as
http://www.google.com/s2/favicons?domain=www.domain.com
Which works fine in returning a valid favicon but it does not return the favicon that my browser uses when I tested it.
Other links from that question are similar, most only returned a 16x16 favicon and many clearly did not return the image used. Some probably didn't return the image used... it is hard to differentiate 16x16px sometimes!
You can use the Compatibility test of RealFaviconGenerator. The test will ask you which icon you see. But there is a twist: the test is not really for the end-user, so you will have to right-click the image corresponding to the icon you see, inspect it, and look at the alt attribute of the img tag. But that will prevent you from playing with 20+ images to make them different. Much easier!
Full disclosure: I'm the author of RealFaviconGenerator.
Note: I would be interested in your investigations to fix the answer you mention (I'm his author).
Using the Inspect Element, or just Inspect tool, available in Firefox and Chromium. The Network tab shows all http operations related to reload. Filtering by 'favicon' most likely peeks the correct operation, when the page is reloaded.
The fact that the browser downloads an image is a strong hint of what gets displayed. Yet, doubts can persist, e.g. which part of an .ICO. Unfortunately, the tab is a computed element not visible in the (computed) page source.
On Firefox, the iconuri is visible in the json code of exported bookmarks.

How do you affect the font-family in a page's window title? [duplicate]

I've noticed an interesting anomaly when running Chrome 40.0.2214.10 beta-m (64-bit) on Win7. Admittedly, I have yet to test this on other browsers.
In the screenshot below you will see to eBay item pages -- the first has a title which renders as a Serif (is that Times New Roman) in the Chrome Title Tab. The latter renders in the standard Sans-Serif Chrome font.
The URL for the first example is here: http://ebay.com/itm/301399607776
My principle question is whether or not this is something that I can reproduce using any combination of markup, javascript or other file or server-side settings -- or whether or not this is some kind of unusual bug or setting in my local browser settings.
This is a bug with certain characters in Chrome, if you copy and paste (for example, into a Chrome URL bar):
Mens Mickey Mouse T Shirt
You will see the rendering issue appear in the Input Form. (Note: the character U+0091 appears between the "n" and "s" in "Mens" here.)

Anyone have a flowchart for determining what document mode IE10 will use, like this one for IE9?

I found this completely wonderful document that shows the information I want, but for IE9. This helped clear up a lot of confusion I had about how IE document modes work:
http://ie.microsoft.com/testdrive/ieblog/2010/Jun/16_IEsCompatibilityFeaturesforSiteDevelopers_1.svg
I've searched for an updated version for IE10 but haven't found anything. Anyone seen the equivalent but updated?
My experience so far with msdn's documentation such as their Defining document compatibility has been very frustrating, with a lot of going in circles and undefined terms.
Particularly, the question I've been unable to answer (though really I'm only looking for the answer still because I'm frustrated that it's not provided anywhere) is this: Does IE10 Compatibility Mode still mean it's emulating IE7? I guess I assume that it does, but it annoys me immensely that nothing seems to say so explicitly. Mad props to anyone who can find someplace that the MSDN documents say whether it does or not.
I was also looking for an updated diagram, and found the following after doing a Google image search (scroll to bottom):
http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx
There are links on the left to take you to the compatibility view settings and doctype table, as they're not included in the flow chart on the page.
For your second question, about whether Compatibility Mode is still emulating IE7, I assume you mean that you get to IE10 Compatibility Mode by clicking the icon in the browser and not by setting a meta tag or header. I believe the answer is yes, but not because I have seen it in Microsoft's documentation. When I click that icon and look in Developer Tools, I see that the Browser Mode is "IE10 Compatibility" and the Document Mode is "IE7 Standards" so it seems like that's the default. You can see this happen on nytimes.com.

Links disabled in html

I've been working on a revamp of the charity site I'm the webmaster for, heroinitiative.org. It is located here:
http://www.heroinitiative.org/revamp/default.html
(and no it's not live code, it sits alongside the live site just so I can show progress to my boss, it's not really important to keep it under wraps, which is why I can post it here)
My problem: For some reason all links in the footer (from id "bodyfooter" on down, including anything I put below the "Partners/Thanks" footer) have been disabled. I don't know why this is happening as I've thoroughly reviewed the code.
It happens in:
Firefox 3.6.8
Chrome 5.0.375.127 & 6.0.472.53 (just upgraded as I typed this)
but not in:
IE 8.0.7600.16385 (or in it's compatibility mode)
you have a z-index:-1 on #bodyfooter. main.css line 182
remove this or change it to 0.
Your page takes a long time to display in Safari on my Mac.
Whenever I have a page that does not render as I expect, I run it through the W3C Markup Validation Service.
Try fixing the errors displayed here:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.heroinitiative.org%2Frevamp%2Fdefault.html&charset=%28detect+automatically%29&doctype=Inline&group=0