How does the content property inherit in: before or: after a pseudo-element from its container?

Consider this HTML / CSS script:

p { content:'x'; }
p:before, p:after { content:inherit; }
<p></p>
Run code

Firefox will display "xx". In Chrome and IE nothing is displayed.

When evaluating what I think should happen, I took into account the following snippets from the CSS 2.1 specification:

12.1: before and: after pseudo-elements

: before and: after pseudo-elements inherit any inherited properties from the element in the document tree to which they relate attached.

So, in the general case, property inheritance in: before and: after pseudo-elements from their containing element should work (and it works for other properties).

12.2 Property "content"

''    : | | [| | | attr() | | | no-open-quote | no-close-quote] + |

, "inherit" content

: On "normal". On: before : after, "normal", "none". URI - URI; attr(), ; , .

, . , , <p> , normal

:: before :

1.4.2.3

, . , ....

, " " , , CSS .

6.2.1 "inherit"

'inherit', . "inherit" , , .

, , . <p> content "x" .

, IE DOM, p normal, "x" . , .

Chrome DOM p ! Chrome - , . window.getComputedStyle(el).content "x". Firefox, , .

Firefox DOM p "x" . , , normal. .

, , Firefox, IE Chrome - , Firefox "xx" .

- ?

+4
1

, , , . CSS ?

- w3.org, , , inherit, , `

> [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote |
> close-quote | no-open-quote | no-close-quote ]+`

, , . ...?

, , , . , , .

. , , , , , , : , : before, if: before . https://css-tricks.com/pseudo-element-roundup/

. , firefox - , - , . http://jsfiddle.net/8Lsp7c7j/1/

-1

Source: https://habr.com/ru/post/1589320/


All Articles