- From: Simon Sapin <simon.sapin@exyr.org>
- Date: Mon, 28 Oct 2013 17:26:19 +0000
- To: www-style@w3.org
Le 28/10/2013 17:22, Tab Atkins Jr. a écrit : > On Sat, Oct 26, 2013 at 11:01 AM, Jon Rimmer <jon.rimmer@gmail.com> wrote: >> Hi all, >> >> I'd like to propose a text() function that returns an element's inner-text, >> similarly to how attr() returns the value of an attribute. >> >> The use-case for this is creating pseudo-elements that replicate the text of >> the element for decorative purposes. For example, see the following list of >> link effects: >> >> http://tympanus.net/Development/CreativeLinkEffects/ >> >> Most of the effects require the text of the link to be duplicated in a >> data-hover attribute so it can be referenced via content: attr(data-hover). >> This same technique can found in other places [1][2][3] but is hardly an >> ideal practice, given the duplication of content it requires. >> >> [1] >> http://stackoverflow.com/questions/7175113/content-attribute-to-inherit-node-value >> [2] >> http://blog.adrianroselli.com/2012/10/chromatic-type-with-pseudo-elements.html >> [3] http://www.dynamicdrive.com/style/csslibrary/item/rollover_text_menu/ > > Note that the text-content wont' be enough for those decorative > effects if there's any stylistic markup inside of it; for example, if > one word in the element is italicized, the pseudo-element's contents > won't be. > > If that's an acceptable limitation, then this seems reasonable. I'm > not sure that it is, though. Apparently the alternative is to use attr() with a data-* attribute, which can only contain non-styled text as well. -- Simon Sapin
Received on Monday, 28 October 2013 17:26:43 UTC