
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Styling Links Working with CSS
CSS allows us to style links as desired. We can format text, by adding colors, background, increase size, etc. Furthermore, animations can be added to create a pleasant visual effect.
For proper functionality, the order of pseudo selectors is given by:- :link, :visited, :hover, :active.
Example
The following examples illustrate styling of links with CSS −
<!DOCTYPE html> <html> <head> <style> p { margin: 25px; } #mod { padding: 10px; color: darkturquoise; border: thin solid; background-color: lemonchiffon; } #mod:hover { color: white; box-shadow: 0 0 0 1px black; background-color: slateblue; } </style> </head> <body> <p> <a href="mailto:user@example.com">Demo link</a> </p> <p> <a id="mod" href="mailto:user@example.com">Modified demo link</a> </p> </body> </html>
Output
This gives the following output −
On hovering the second link, we get the following output −
Example
<!DOCTYPE html> <html> <head> <style> div { margin: 25px; display: flex; float: left; border: thin solid; background-color: snow; padding: 20px; } body * { border-radius: 5%; } #mod { padding: 10px; color: royalblue; text-decoration: none; } #mod:hover { box-shadow: 0 0 10px 2px black; text-decoration: overline; font-size: 1.2em; } </style> </head> <body> <div> <button><a href="#">Demo</a></button> <a id="mod" href="#">Demo</a> </div> </body> </html>
Output
This gives the following output −
On hovering the second link, we get the following output
- Related Articles
- Styling Links with CSS
- Styling Tables Working with CSS
- Styling Tables with CSS
- Styling Lists with CSS
- Styling Forms with CSS Attribute Selectors
- Styling First-Letters with CSS ::first-letter
- Style all unvisited links with CSS
- Style all visited links with CSS
- Styling Lists in CSS
- Working with Inline CSS
- Working with CSS Units
- Set the Color of links with CSS
- Style links on mouse over with CSS
- Add space between pagination links with CSS
- Set the Color of Visited Links with CSS

Advertisements