- 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
Standard Link Styles in CSS
We can style links as per our requirements. It is recommended that links have styles which distinguish them from normal text. The default link styles for different link states is as follows −
Link State |
Color |
---|---|
active |
#EE0000 |
focus |
#5E9ED6 or a similar shade of blue outline in case of Windows and Mac, #F07746 outline for Linux while text color remains the same |
hover |
#0000EE |
link |
#0000EE |
visited |
#551A8B |
Note − The above colors may change with newer versions of browsers. For proper functionality, the order of pseudo selectors is given by:- :link, :visited, :hover, :active.
Standard Link
The following examples illustrate standard link styles −
Example
Let us see now see the code −
<!DOCTYPE html> <html> <head> <style> * { text-align: center; } </style> </head> <body> <h2>Learn JDBC</h2> <a href="">Click here</a> <br/><br/> <a href="#">And here <img src="https://www.tutorialspoint.com/jdbc/images/jdbc-mini-logo.jpg"></a> </body> </html>
Non-standard link
We have set a link here and the text decoration is removed using the text-decoration property with the value none −
Example
Let us see now see the code −
<!DOCTYPE html> <html> <head> <style> #one { color: black; text-decoration: none; } #two { font-style: italic; box-shadow: inset 0 0 8px coral; } table, td { font-size: 1.4em; padding: 8px; text-align: center; border: thin solid; } </style> </head> <body> <table> <tr> <td><a id="one" href="#">1</a>(non standard link)</td> <td id="two"><a href="#">2</a></td> </tr> <tr> <td><a href="">3</a></td> <td><a href="#">4</a></td> </tr> </table> </body> </html>
Manipulate links with CSS Pseudo-classes
When we create a link using the <a> element, then various pseudo classes are used to set the link color, visited link color, hover , active link, etc. We have achieved the same using the pseuso-classes −
a:link { color: rgb(17, 0, 255); } a:visited { color: rgb(128, 0, 107); } a:hover { color: rgb(255, 105, 243); } a:active { color: rgb(255, 153, 0); }
Example
Let us see now see the code −
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } a { font-size: 18px; font-weight: bold; } a:link { color: rgb(17, 0, 255); } a:visited { color: rgb(128, 0, 107); } a:hover { color: rgb(255, 105, 243); } a:active { color: rgb(255, 153, 0); } </style> </head> <body> <h1>Pseudo class example</h1> <a href="#">This is some sample link text</a> <h2>Hover, click on the above link to see the pseudo class in action</h2> </body> </html>