Faisal Alvi
Faisal Alvi

Reputation: 532

Add HTML code using CSS

html

<div id="mydiv"></div>

I want to add HTML code into this div (see following result I want) using ONLY CSS

<div id="mydiv"><a href="#">Lorem</a></div>

I think :after and :before are not helpful here!

Upvotes: 1

Views: 128

Answers (3)

Rahul Tripathi
Rahul Tripathi

Reputation: 172448

CSS is not HTML. It is not possible to achieve that as CSS is not a markup language.

Just to add you can add content but not the element using :before or :after pseudo-element. Refer the specs

Upvotes: 1

jhuiting
jhuiting

Reputation: 66

You can use content (just for text) in a couple of browsers but it's a really bad idea. Please solve this differently e.g. with Javascript, you'll need to for HTML anyway.

Upvotes: 0

user4563161
user4563161

Reputation:

You shouldn't do this for many reasons.

Firstly its just wrong.

Secondly it is not possible.

Css is not for markup html is.

and I dont even understand why you would want to do this at all.

Upvotes: 0

Related Questions