How to change the mouse hover style without using CSS

Source: Internet
Author: User
We know that in the Web page layout, there are some special circumstances we can not directly use the external CSS style to control the div style, such as a set a:hover, then we do not apply CSS style to change the mouse hover style?

You can use onmouseover (mouse over target) and onmouseout (after moving the mouse pointer) to set the hover style for a label or other HTML tag.

You can use the label directly, regardless of a tag, span tag, div tag, etc.

<a href= "http://www.php.cn/" style= "color: #00F; Text-decoration:none "

onmouseover= "this.style.color= ' #F00 '; this.style.textdecoration= ' underline '"

onmouseout= "this.style.color= ' #00F '; this.style.textdecoration= ' None '" >DIV</a>

The above sets the default style for a hyperlink code, moves the mouse over the target, and then moves the mouse over the target style. Feature code is longer.

Important note: In order to see the same as the default style when the mouse is moved, it is often necessary to set the default CSS style directly to the label using style and keep the same CSS style as the onmouseout setting. Prevent the initial state object style from being different from the style after the mouse has been moved off the object.

As above code:

style= "COLOR: #00F; Text-decoration:none "  and onmouseout=" this.style.color= ' #00F '; this.style.textdecoration= ' None ' "

Sets the default font color #00f and does not display underscores.

To implement hover style setup methods with regular hover and without external hover, the case is as follows

Complete General external CSS Case presentation code:

<! DOCTYPE html> 

HTML code and browser effect illustration

DIV css default and mouse hover browser test effect

Default and mouse hover browser test effect

External CSS style conversion after HTML source code

<! DOCTYPE html> 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.