Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

Advanced Link Underlines in CSS

Curious if I can do either of the following with CSS?

1.) Make a link blue, but have the underline red?  (different colors for the link text and link underline.)

2.) Make the spacing between the text different than normal.  So I would have the text, and instead of the underline where it normally is have the underline say 10 px, or 15 px below the text?

Thanks.  I’m not a CSS expert and have no idea if these are possible.  I'm sure even if not directly possible with CSS that there could be some workaround to get these features working.

Andrew
0
rebies
Asked:
rebies
  • 4
1 Solution
 
GrandSchtroumpfCommented:
> 1.) Make a link blue, but have the underline red?  (different colors for the link text and link underline.)
no, but you can use blue text with a red bottom border, which will have a similar effect.

> 2.) Make the spacing between the text different than normal.  So I would have the text, and instead of the underline where it normally is have the underline say 10 px, or 15 px below the text?
this can also be done with a border.  just specify a bottom padding for your text and the bottom border will be shifted down.
0
 
GrandSchtroumpfCommented:
here is an example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />

<style type="text/css">

div {
  line-height: 2em;
}
a {
  color: blue;
  border-bottom: 2px solid red;
  padding-bottom: .3em;
  text-decoration: none;
}

</style>

</head>

<body>

<div>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla rhoncus vehicula nisl. Duis eleifend ante a lorem. Quisque non nulla sed ante aliquam porttitor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque posuere dolor eu lorem.

<a href="www.google.com">www.google.com</a>

Integer et est sit amet enim porttitor tristique. Suspendisse nec nisl. Duis pellentesque. Proin ultricies. Maecenas pharetra suscipit eros. Fusce fermentum imperdiet nunc. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer rutrum enim eu risus.
</div>

</body>
</html>
0
 
GrandSchtroumpfCommented:
note that you can remove the following line:
<link href="style/style.css" rel="stylesheet" type="text/css" />
i forgot to delete it.
0
 
rebiesAuthor Commented:
GrandSchtroumpf:

Sorry I did not respond earlier!  Thanks so much!  That is exactly what I was looking for.  So very cool!

A+++

Andrew
0
 
GrandSchtroumpfCommented:
<:°)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now