Add HTML tag inside CSS Content property

Muhammad Reda picture Muhammad Reda · Mar 19, 2014 · Viewed 20.1k times · Source

I'm looking for a way to add an HTML tag for CSS content property inside :after and :before.

Unlike this question which only discusses adding symbols like <. What I'm trying to add is something like:

.breadcrumbs li a:before {
    content: '<i class="icon"></i>';
}

Is there any possible way to do that?

Answer

Quentin picture Quentin · Mar 19, 2014

This is impossible. You cannot generate markup from CSS.

It should also be unnecessary - stick your background image / icon font / whatever in the generated pseudo-element you have already.