Enhancing Links

Adorn the Gates to a New World

Links are like magical portals, guiding your visitors to distant realms and new adventures. With a touch of CSS, you can not only open these gates but also decorate them with radiant colors and enchanting effects. Give your links unique hues, graceful underlines, or make them glow mysteriously when hovered over.

But beware, not every gate should look the same! Let important links shine in vibrant colors, while subtle links maintain an air of elegance.
And the best part? With hover effects, you can make the magical moment of clicking even more interactive, ensuring every visitor finds their way through your digital realm with ease!

Links with Style

Decorate, focus, react – make connections come alive!

Token: Styling Links

Styling Links

Color, Underline & Transition

With CSS, you can unlock the full magic of your link elements. Use text-decoration for elegant underlines, color for vibrant hues, and transition to create smooth hover effects. This transforms your links into not just interactive elements but true visual delights.

a {
    color: orange;
    text-decoration: none;
    transition: 0.3s;
}

Set all links in the document to a bold orange color, removing the underline. A soft transition effect ensures that hovering over them feels seamless and engaging.

Token: decoration

Decoration

Adorning the Digital Gateways

Imagine decorating a grand gate to welcome your visitors. With CSS, you can turn links into true masterpieces. Underlines, shadows, or even a touch of mysterious glow add that special flair to your digital doorways. Using the shorthand text-decoration combined with underline, you can create truly distinctive accents.

a {
    text-decoration: 2px dotted red underline;
}

Here, each link receives a red dotted underline with a thickness of 2px:

Pseudo-Classes

Unlocking the Hidden States of Your Links

Pseudo-classes are magical keywords in CSS that reveal the hidden states of an element. For links, you can use these spells to create unique effects depending on their state—whether untouched, visited, or hovered over. By applying these enchanting states, you can elevate the user experience significantly. These pseudo-classes always begin with a colon (:).

Token: hover

Hover Effects

The Magic of Interaction

The :hover pseudo-class unleashes its magic as soon as a user hovers over a link with their mouse. In this fleeting moment, you gain the power to transform the link in a truly captivating way.

a:hover {
    color: green;
}

In this example, the link changes its color to green when hovered over.

The Moment of the Click

The Magic of Touch

The :active pseudo-class reveals its power precisely at the instant a link is clicked. This brief magical moment makes the link visually stand out, confirming the interaction.

a:active {
  color: red;
}

In this example, the link changes its color to red when clicked.

In the Spotlight

The Magic of Focus

The :focus pseudo-class gives an element special attention once it is activated or selected, whether by a click or using the Tab key. This magical glow ensures accessibility to the interactive element.

a:focus {
    outline: 2px solid #ff5733;
    outline-offset: 4px;
}

In this example, the link receives a red outline with spacing around it when activated via the Tab key.

link & visited

The Untouched Path & the Explored Trail

The :link pseudo-class sets the style for links that have not yet been clicked, representing its untouched state. In practice, however, it is often replaced by general link styles. The :visited magic, on the other hand, transforms the appearance of links that have already been explored. Due to magical security restrictions, you can only make simple changes like adjusting the color.

Magical Scrolling

The Art of Smooth Transitions

With scroll-behavior: smooth;, your page glides gracefully to its target anchor, avoiding the jarring jumps that can unsettle even the most patient visitors.

html {
    scroll-behavior: smooth;
}

Smooth scrolling to the next anchor

CSS
.link a {
    color: orange;
    text-decoration: none;
    transition: 0.3s;
}

.link a:hover {
    color: green;
}

.link a:active {
    color: red;
}

.link a:focus {
    outline: 2px solid #ff5733;
    /* Color and thickness of the border */
    outline-offset: 4px;
    /* Distance from element */
}

/* Design a button */
.btn {
    text-decoration: none;
    background-color: purple;
    border-radius: 5px;
    padding: 10px 15px;
    color: white;
    transition: 0.3s;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
}

.btn:hover {
    background-color: pink;
    color: black;
}

.test {
    text-decoration: none;
    border: 2px solid purple;
    border-radius: 5px;
    padding: 10px 15px;
    color: purple;
    transition: 0.3s;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
}

.test:hover {
    border: 2px solid pink;
    color: pink;
}
Scroll to Top