1

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!

1
  • 1
    It's not possible, CSS isn't markup language. Commented May 15, 2015 at 11:57

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.