tags:

views:

58

answers:

4

Hello All,

Is it possible to use CSS's 'content' property using inline CSS something like this:

<p class="myclass" style=".myclass:after:content = 'my content here'">Hello There !!</p>
A: 

I think you mean something like this:

<html>
  <head>
    <style>
      .myclass:after {
        content: "my content here";
      }
    </style>
  </head>
  <body>
    <p class="myclass">Hello There</p>
  </body>
</html>
Pär Wieslander
A: 

There exists a working draft on Syntax of CSS rules in HTML's "style" attribute.

If it works as in the WD you should be able to do something like:

<p class="myclass" style="{color: #C00; font-weight: bold} :after {content: 'my content here'}">Hello There !!</p>
anddoutoi
Sadly I think that working draft is pretty much dead. It's not been updated since May 2002, and to my knowledge no browser has implemented it.
Chris
And as Chris says (and after I tested in fx3.5.5 and ie8) it don´t seem to work =P
anddoutoi
this would be nice. I'm trying to use CSS in SharePoint pages without resorting to SharePoint Designer.
John Ferguson
+3  A: 

No. Inline styles via the 'style' attribute can only be applied to the context element, without any selectors of any sort.

Chris
A: 

You can't use selectors in style attributes, so I would say no.

You can still put the style in the html file, like so:

<style type="text/css">
    .myclass:after { content: 'my content here'; }
</style>
...
<foo class="myclass">Hello There!!</foo>
Rasmus Kaj