:hover pseudo class in style attribute

Posted on 2009-12-28
Last Modified: 2012-05-09
In the css specification there is outlined how to put pseudo classes in HTML's style attribute.

I have tried to get this working but have not been successful. I need this because with javascript I would rather tack on a css hover inline than state a javascript event for the effect.

Has anyone ever got inline pseudo classes to work?

I do not need solutions for how to get hover to work with javascript or by stating the pseudo class outside of inline, I can code that any day. My question is a topic of just inline pseudo classes.

Thank you for your support!

Here is an example of a test that does not work in FF 3.5 or IE8.
<div style="{color:#000; background-color:#ff0000;}:hover{background-color:#fffff0; color:#fff;}">Hover me</div>

Open in new window

Question by:the_hero
    LVL 16

    Accepted Solution

    Pseudo classes only work with some selectors such as anchor tags. I don't think you can apply them to a div tag.
    LVL 1

    Author Closing Comment

    I see. Thanks for your help. I sure wish that the standard wasn't limited like that.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Adobe Dreamweaver CC 2015

    Adobe Dreamweaver Creative Cloud is used by web designers and front-end developers and allows you to visualize your site in real-time as you code. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    Suggested Solutions

    Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
    The viewer will learn how to dynamically set the form action using jQuery.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now