CSS Links
With CSS, links can be styled in many different ways.
Text Link Text Link Link Button Link Button
Styling Links
Links can be styled with any CSS property (e.g. color
, font-family
, background
, etc.).
Example
a {
color: hotpink;
}
In addition, links can be styled differently depending on what state they are in.
The four links states are:
a:link
– a normal, unvisited linka:visited
– a link the user has visiteda:hover
– a link when the user mouses over ita:active
– a link the moment it is clicked
Example
/* unvisited link */
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: hotpink;
}
/* selected link */
a:active {
color: blue;
}
When setting the style for several link states, there are some order rules:
- a:hover MUST come after a:link and a:visited
- a:active MUST come after a:hover
Text Decoration
The text-decoration
property is mostly used to remove underlines from links:
Example
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
Background Color
The background-color
property can be used to specify a background color for links:
Example
a:link {
background-color: yellow;
}
a:visited {
background-color: cyan;
}
a:hover {
background-color: lightgreen;
}
a:active {
background-color: hotpink;
}
Link Buttons
This example demonstrates a more advanced example where we combine several CSS properties to display links as boxes/buttons:
Example
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
More Examples
Example
This example demonstrates how to add other styles to hyperlinks:
a.one:link {color: #ff0000;}
a.one:visited {color: #0000ff;}
a.one:hover {color: #ffcc00;}
a.two:link {color: #ff0000;}
a.two:visited {color: #0000ff;}
a.two:hover {font-size: 150%;}
a.three:link {color: #ff0000;}
a.three:visited {color: #0000ff;}
a.three:hover {background: #66ff66;}
a.four:link {color: #ff0000;}
a.four:visited {color: #0000ff;}
a.four:hover {font-family: monospace;}
a.five:link {color: #ff0000; text-decoration: none;}
a.five:visited {color: #0000ff; text-decoration: none;}
a.five:hover {text-decoration: underline;}
Example
Another example of how to create link boxes/buttons:
a:link, a:visited {
background-color: white;
color: black;
border: 2px solid green;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: green;
color: white;
}
Example
This example demonstrates the different types of cursors (can be useful for links):
<span style="cursor: auto">auto</span><br> <span style="cursor: crosshair">crosshair</span><br> <span style="cursor: default">default</span><br> <span style="cursor: e-resize">e-resize</span><br> <span style="cursor: help">help</span><br> <span style="cursor: move">move</span><br> <span style="cursor: n-resize">n-resize</span><br> <span style="cursor: ne-resize">ne-resize</span><br> <span style="cursor: nw-resize">nw-resize</span><br> <span style="cursor: pointer">pointer</span><br> <span style="cursor: progress">progress</span><br> <span style="cursor: s-resize">s-resize</span><br> <span style="cursor: se-resize">se-resize</span><br> <span style="cursor: sw-resize">sw-resize</span><br> <span style="cursor: text">text</span><br> <span style="cursor: w-resize">w-resize</span><br> <span style="cursor: wait">wait</span>
43 Responses
order levofloxacin 500mg generic purchase levaquin online cheap
buy avodart 0.5mg generic brand flomax 0.2mg buy zofran pills
buy aldactone generic spironolactone 100mg drug buy diflucan generic
purchase ampicillin online buy acillin generic order erythromycin 500mg pills
brand sildenafil 100mg robaxin pills methocarbamol usa
buy sildenafil 100mg generic aurogra medication estradiol online buy
lamotrigine order online lamictal 200mg tablet buy tretinoin cream online cheap
tadalafil 10mg cheap purchase voltaren online cheap order voltaren
buy accutane 10mg generic cheap amoxicillin buy generic zithromax
buy generic indomethacin 50mg order trimox 500mg online cheap trimox 500mg drug
tadalafil india price for cialis viagra 100mg usa
arimidex us buy anastrozole for sale buy sildenafil online
tadalafil 20mg sans ordonnance cialis 5mg sans ordonnance en france acheter 200mg gГ©nГ©rique sildenafil en france
deltasone 5mg tablet tadalafil cheap viagra australia
tadalafil kaufen ohne rezept original tadalafil 10mg rezeptfrei sicher kaufen sildenafil kaufen ohne rezept
buy accutane 10mg sale amoxil ca ivermectin 12 mg tablets for humans
modafinil 100mg uk buy modafinil 200mg pill diamox 250mg pill
buy doxycycline pills order levitra 20mg pill brand lasix
buy ramipril for sale astelin for sale online buy astelin
order generic catapres 0.1 mg catapres 0.1mg price spiriva 9 mcg sale
order buspar 10mg online buy buspirone 10mg oxybutynin 5mg without prescription
buy hytrin 5mg generic azulfidine 500 mg for sale purchase azulfidine sale
cheap fosamax 35mg pepcid 40mg price oral pepcid
order benicar generic verapamil 240mg for sale buy acetazolamide sale
tacrolimus 1mg ca order prograf generic purchase urso for sale
order isosorbide 20mg without prescription micardis 80mg price telmisartan 80mg canada
zyban usa seroquel without prescription buy seroquel 50mg for sale
purchase molnunat generic cefdinir 300mg for sale prevacid uk
zoloft 50mg price Buy online viagra viagra 50mg canada
salbutamol 100mcg uk buy imuran 100mcg sale sildenafil for men over 50
cialis india real cialis fast shipping buy viagra 50mg without prescription
order revia 50 mg generic buy aripiprazole online cheap aripiprazole 20mg pill
avlosulfon online order dapsone sale aceon 4mg drug
order medroxyprogesterone 5mg pill order cyproheptadine 4 mg sale order periactin 4 mg pill
provigil 100mg without prescription stromectol for people ivermectin coronavirus
fluvoxamine without prescription order ketoconazole 200 mg without prescription glipizide 5mg without prescription
isotretinoin 20mg pill accutane 20mg canada buy prednisone 40mg online cheap
buy piracetam 800mg sale buy sildenafil pill generic sildenafil 50mg
zithromax brand neurontin 800mg usa order gabapentin 800mg without prescription
cialis mail order generic sildenafil sildenafil generic
buy lasix buy furosemide 100mg pill hydroxychloroquine 400mg oral
brand tadalafil generic cialis cost purchase clomipramine sale
chloroquine 250mg for sale buy cenforce 100mg without prescription order baricitinib 4mg generic