0

I know that with CSS you can do for example:

p:hover {
    xxx:yyy;
}

I wish to do so but in the HTML page without linking the CSS, like so:

<p style="xxx">xxxxxxxx</p>

but with the hover option.

1

3 Answers 3

3

You can insert directly your CSS inside the html page without linking it:

<head>
<style>
    p:hover {
        xxx: yyy;
    }
</style>
</head>
<body>
    <p>xxxxxxxx</p>
</body>

Internal Style Sheet

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

1 Comment

Thanks, i forgot to mention that i do have the option to edit the <head> i can only use the body.
0

You can simply use internal css in your html page as below..

<style>
 p:hover{
  //coding...
  }
</style>

Comments

-1

Try JavaScript:

<p onmouseover="change(this)" >xxxxx</p>
<script type="text/javascript" >
  function change (element) {
    var style = element.style;
    // Do something with style...
    // Example: style.color = "red";
  }
</script>

6 Comments

Didn't think about using JS! thanks for the answer, but do i need an external JS page for this? i need everything in the same page.
thanks for the answer works like a charm. how can i make the red disappear after removing the mouse?
You don't need a external JS page, just use the script tag.
You can try onmouseout to remove the style.
Oh but how can I add both the onmouseover and onmouseout on the same text without resolving to a separate JS page?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.