Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you apply the css rule `content` to child elements?

Tags:

css

Can you apply the ccs rule content to child elements?

css :

a:link:before, a:visited:before{
    content: " "attr(href)" ";
}

html :

<a href="/home">Home</a>

Result :

 -------------
|    /home    |
|    Home     |
 -------------

However I would like to do the following:

html :

<a href="/home"><span>home</span></a>

With the previous css the href value would appear before the span.

Is it possible to make it appear in the span?

I've tried this. It's for a sitemap.

like image 793
Sparkup Avatar asked Oct 10 '22 04:10

Sparkup


1 Answers

No, that's not possible.

To make generated content render inside the span, you need a:link span:before.

Unfortunately, in that case, content: " "attr(href)" "; will no longer work, because the a element is no longer the subject of the selector - the span is, and the span does not have the href attribute.

like image 95
thirtydot Avatar answered Oct 14 '22 02:10

thirtydot