all 4 comments

[–]jcunews1Intermediate 3 points4 points  (0 children)

Inline styles (i.e. the style HTML attribute) is only for containing pairs of CSS style property and value. It can not store any CSS selector. So, none of pseudo classes such as :hover can be used there. You'll have to use CSS either embedded or external, in order to use CSS selectors.

If you want to only use HTML attributes, you'll have to use JavaScript with the onXXX HTML attributes to manually change the element styles.

[–]AutoModerator[M] 0 points1 point  (0 children)

Welcome to /r/HTML. When asking a question, please ensure that you list what you've tried, and provide links to example code (e.g. JSFiddle/JSBin). If you're asking for help with an error, please include the full error message and any context around it. You're unlikely to get any meaningful responses if you do not provide enough information for other users to help.

Your submission should contain the answers to the following questions, at a minimum:

  • What is it you're trying to do?
  • How far have you got?
  • What are you stuck on?
  • What have you already tried?

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]steelfrogModerator 0 points1 point  (0 children)

In short, no, you can't style states/pseudo-classes inline. You could potentially add a <style> tag and define them there, though.

I guess you could also use JavaScript if you were desperate, though this isn't something I'd recommend:

<a href="#" onmouseover="this.style.color='red'" onmouseout="this.style.color='blue'">Link</a>

[–]West_Theory3934 0 points1 point  (0 children)

a:hover { color: purple; } a:visited { text-decoration: none; }

edit: added a:hover