
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
Difference between :focus and :active selector in HTML
:focus
:focus selector is used to applying a required style when a form element got to focus like button, link, input box. An element can get focus using mouse or using tab key. A focus remains on the element until another element gets focus.
:active
:active selector is used to indicating that an anchor tag is active or a button is active. When the mouse is down, active selector applies and remains applied till the mouse is down.
Example
Following the example, shows usage of :focus as well as :active selector on button and link.
<!DOCTYPE html> <html> <head> <title>Selector Example</title> <style> button { border: 2px solid black; } button:focus { border: 2px dotted red; } a { color: black; } a:active { color: red; } </style> </head> <body> <button type="submit">Focus Me</button> <a href="#">Active Me</a> </body> </html>
Output
- Related Articles
- jQuery :focus Selector
- Difference between "." and "#" selector in CSS
- What is the difference between jQuery(selector) and $(selector)?
- Difference between Active and Passive Speakers
- Role of CSS :active Selector
- Difference between Active and Passive Components (in Electronics)
- Role of CSS :focus Selector
- Difference between Active Attack and Passive Attack
- Difference between Active Transducer and Passive Transducer
- Difference Between Active Calories and Total Calories
- Difference Between Active Learning and Passive Learning
- Difference between Active Power and Reactive Power
- Difference between HTML and HTML 5
- Difference Between :first-child and :first-of-type selector in CSS
- What is the difference between focus and focus_set methods in Tkinter?

Advertisements