- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements