2

You can set html tag style in css like this:

<div class="sample_style"></div>

.sample_style {
    position:absolute;
    ...
}

You can do this in html tag directly like this:

<div style="position: absolute; ..."></div>

But what about before element?

You can do in css like .sample_style:before{} but how can i set this directly in html tag?

mobile_dev
  • 31
  • 1
  • 4

1 Answers1

0

Using Pseudo-classes inline (like :hover, :active, :before,...) is not possible (by default). As far as I know some workaround exists but it is NOT recommended. It is not working for most browsers anyway.

Solution: Use CSS-Classes. It is best practice anyway and better than using inline-styles (reusable & you don't mess up your HTML)

newBee
  • 1,289
  • 1
  • 14
  • 31
  • There are times when inline styles are useful, such as injecting custom styles into a webpage when you do not control the original webpage content. As such, this question can still be valid in cases where the solution cannot use CSS stylesheets. This still, however, doesn't change the answer to the question. – ajp15243 Sep 18 '14 at 13:58
  • I did not meant to say that you should not use inline. However it is better to use class whenever possible as it makes sense in most cases. But yes you're right. – newBee Sep 18 '14 at 14:06