admin管理员组

文章数量:1400157

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.

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.

Share Improve this question edited Jan 1, 2014 at 14:24 Matthew Strawbridge 20.7k10 gold badges79 silver badges96 bronze badges asked Jan 1, 2014 at 14:18 BodokhBodokh 1,0764 gold badges18 silver badges34 bronze badges 1
  • 1 see stackoverflow./questions/5293280/… – db9dreamer Commented Jan 1, 2014 at 14:25
Add a ment  | 

3 Answers 3

Reset to default 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

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

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

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>

本文标签: javascriptHow do I create Hover effects in HTML without using a CSS pageStack Overflow