1

Fragments (or hashes) in URL are widely used to specify some specific fragment in a document.

For example, the fragment below

http://example.com/page.pnp#<fragment>

Usually references something like <div id="<fragment>" /> or <a name="<fragment>" /> in a HTML document.

There is a standard to support CSS selectors as a fragment, like so:

http://example.com/page.pnp#css(<CSS selector>)

Are there any applications using it? Would it be nice for browser to support it? For example, browser could display only the selected fragments of the page or highlight the selected fragments. Or provide an option for developers to highlight the selected fragments with CSS or JS. Can somebody submit it to the relevant browser devs as a feature request?

What are other ways to reference specific content in a HTML page? For example, if I want to comment on some specific element in a HTML page, what are any other ways to specify that position in the document, preferably by using URI, or some other convenient identifier?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Vad
  • 4,052
  • 3
  • 29
  • 34

3 Answers3

1

You can use the :target selector as described here: https://developer.mozilla.org/en-US/docs/Web/CSS/:target

G. Allen Morris III
  • 1,012
  • 18
  • 30
0

The document you link to isn't really a standard; it even says "Unofficial Draft" in the subtitle, and under where it says Status:

This document is merely a public working draft of a potential specification. It has no official standing of any kind and does not represent the support or consensus of any standards organisation.

... so it is completely inappropriate to refer to it as a "standard". A better term for this would be "concept" or "experiment".

That being said, rudimentary implementations exist (or at least, they did at the time it was first published) in the form of browser extensions; you can find links to these in section 8.

AFAIK, though, there hasn't been any activity around this at all after the first few months since the community group for this was formed and I joined. Either it never gained traction or it just wasn't very feasible to implement after all.

For now, as always, fragment identifiers can only point to elements with the respective id attribute, or named anchors. It seems it'll remain that way for the foreseeable future.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • I really need a way to reference specific parts of a document, and then use that URL as an identifier with some RDF vocabulary, say in JSON-LD format. – Vad Mar 02 '15 at 23:00
  • 1
    Fragments were created to be able to reference specific parts in a document, on the client, after the resource has been loaded. It is a shame that there is no good agreed way to reference parts of HTML document now in 2015. For example, there are many apps nowadays that allow your to add comment to a specific "place" on the web. – Vad Mar 02 '15 at 23:07
0

For Chrome, There's a Jquery Fragement selector extension:

With the advent of edge extensions it will likely become easy to implement in edge.

djsadinoff
  • 5,519
  • 6
  • 33
  • 40