-4

I am aware that content can be displayed with css using content

.email-address:before {
   content: "Email address: ";
}

But what if I wanted to do something like this:

.email-address:before {
   content: "<strong class='my text'>Email address:</strong>";
}

is this possible?

4
  • 6
    Why don't you try it and see what happens? it'd probably take LESS time to whip up a test case and run it through your browser than it did for you to type this up and wait for an answer. Commented Aug 13, 2014 at 20:41
  • 1
    nop, but you can do font-weight:bold; and any CSS like any regular inline box. border:solid; float; display:list-item, ... whatever you need Commented Aug 13, 2014 at 20:41
  • @ctwheels Why would you use JS for it? Commented Aug 13, 2014 at 20:50
  • @MarcB i have tried it before posting this question. I just posted this to make it clear what i am trying to do. Commented Aug 14, 2014 at 17:02

2 Answers 2

3

No, but.

What you can do is :

.email-address:before {
   content: "Email address: ";
   font-weight:bold;
}

and or :

.email-address:before, .my-text {
    /* Rules for my-text */ 
}

<edit>

If your idea was to retrieve some pieces of text you can use data-attributes.

<p class="email-address" data-name="myName" data-com="mydomain.com"></p>

and

.email-address:before {
   content: "Email address: "attr(data-name)'@'attr(data-com);
   font-weight:bold;
}

demo

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

Comments

0

No. No DOM element will be altered. The content will be only referenced as text and not HTML.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.