0

Is it possible to get the content of a tag using content in css?

a::after {
    content: whatever is contained within the a tag
}

I am trying to implement Inline elements shifting when made bold on hover

Tristanisginger
  • 2,181
  • 4
  • 28
  • 41
  • What you mean with body of a tag? Html is build using elements. `:after` is a pseudo element. Beside that css is a tool to create styles not to retrieve data. Javascript is used for that. What are you trying to achieve? – Mark Baijens Sep 21 '18 at 10:38
  • 1
    Unsure if you can do this with pure CSS, but it can be achieved by mixing it with JavaScript. @MarkBaijens my guess is he means whatever content is within the tag (going by his sugar code example). – Martin Sep 21 '18 at 10:40
  • 3
    I'm afraid not. Only `attr` from CSS can get element attributes. https://davidwalsh.name/css-content-attr In addition, this `attr` only support `content` attribute. https://caniuse.com/#feat=css3-attr – Toan Lu Sep 21 '18 at 10:40
  • better use javascript – charan kumar Sep 21 '18 at 10:44
  • thanks i've updated the question. I ended up using attr(title) – Tristanisginger Sep 21 '18 at 11:23

0 Answers0