w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.42k stars 651 forks source link

[css-values] Get the URL of the current document #6546

Open hober opened 3 years ago

hober commented 3 years ago

One of the use cases for #6544 is to provide a QR code that, when scanned, would be the URL of the current document. But apparently there's no way to get the URL of the current document from CSS.

From #css today:

[18:33] <hober> Ooooh, very simple CSS question that I apparently don't         
                know the answer to: How can I, from CSS, get a URL to           
                the current document? Not the current stylesheet, the           
                current document. What to pass to url()?                        
[18:36] <cbiesinger> I didn't think that was possible                           
[18:39] <hober> oh, booo. filed                                                 
                https://github.com/w3c/csswg-drafts/issues/6546                 
plinss commented 3 years ago

Seems like something that would be useful in the content: of headers/footers of print style sheets as well.

faceless2 commented 3 years ago

I can confirm it is very useful for print headers/footers - we use a non-standard env(location) for this. To fully cover most headers/footers you'd also need another env() to retrieve the current date.

Crissov commented 3 years ago

Which of these would have the same value?

tabatkins commented 3 years ago

The function might want some options to control what shows up, but I assume that by default we'd use the scheme, domain, path, and query, ignoring the credentials and hash.