Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my original comment, I said:</p> <blockquote> <p>I don't think this is possible as content within the <code>progress</code> element is never displayed if the browser can already draw the progress bar, similarly to content within an <code>object</code> or <code>iframe</code>.</p> </blockquote> <p>To put it another way, this classifies <code>progress</code> as a <a href="http://www.w3.org/TR/CSS21/conform.html#replaced-element">replaced element</a>. Just as with the traditional <code>input</code> and other form elements that are replaced elements, as well as <code>img</code>, <a href="http://www.w3.org/TR/CSS21/generate.html#before-after-content">CSS2.1</a> doesn't have much to say about using generated content with it:</p> <blockquote> <p><strong>Note.</strong> This specification does not fully define the interaction of :before and :after with replaced elements (such as IMG in HTML). This will be defined in more detail in a future specification.</p> </blockquote> <p>It's well-established that Gecko-based browsers choose not to support generated content for replaced elements, whereas WebKit-based browsers allow it to some extent, at least for form elements that are replaced elements. (Interestingly, <code>progress::before</code> and <code>progress::after</code> do not work in <em>any</em> browser.) So if you're asking if it's possible to do this cross-browser, the answer is no, and has always been no.</p> <hr> <p>As for why WebKit browsers can insert strings and not <code>attr()</code> values, I'm not certain. Both <a href="http://www.w3.org/TR/CSS21/generate.html#content">CSS2.1</a> and <a href="http://www.w3.org/TR/css3-values/#attr-notation">CSS3 Units and Values</a> state that <code>attr()</code> should take values from attributes of the actual element generating those pseudo-elements, since pseudo-elements can't have attributes themselves <em>anyway</em>. This is where I'm stumped.</p> <p>Perhaps the browser is incorrectly trying to take the <code>data-value</code> attribute from <code>::-webkit-progress-bar</code> and <code>::-webkit-progress-value</code> and not the <code>progress</code> element, which is why <code>content</code> is failing when using <code>attr()</code> but working when using a string.</p> <p>Perhaps the root of the problem lies in the very fact that you're trying to add generated content to other pseudo-elements, which again seems to work in WebKit browsers for whatever bizarre reason. Unlike the above issue with generated content within replaced elements, the current <a href="http://www.w3.org/TR/selectors/#selector-syntax">Selectors 3</a> spec and the upcoming <a href="http://www.w3.org/TR/selectors4/#subject">Selectors 4</a> spec are both very clear on this: you are not supposed to have more than one pseudo-element per complex selector. Of course, WebKit has infamously flouted various rules when it comes to implementing pseudo-elements, so in hindsight it does not surprise me to see WebKit mess up doing so.</p> <p>Either way, the real conclusion is that the implementation of CSS generated content is extremely poor beyond the scope of the current standard of CSS2.1 + Selectors, by which I mean generated content for replaced elements such as <code>input</code> and <code>progress</code>, and nesting of pseudo-elements in a single selector.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload