Tutorials Logic, IN +91 8092939553 info@tutorialslogic.com
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Interview Questions Website Development
Compiler Tutorials

CSS Links and Lists

Styling Links

Links have four states that can be styled independently using pseudo-classes. The order matters - use the LVHA rule: :link, :visited, :hover, :active.

Link States and Styling
/* LVHA order is important! */
a:link    { color: #3498db; text-decoration: none; }
a:visited { color: #9b59b6; }
a:hover   { color: #2980b9; text-decoration: underline; }
a:active  { color: #e74c3c; }
a:focus   { outline: 2px solid #3498db; outline-offset: 2px; }

/* Button-style link */
.btn-link {
    display: inline-block;
    padding: 10px 24px;
    background-color: #3498db;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.2s;
}
.btn-link:hover { background-color: #2980b9; color: white; }

/* Underline animation */
.animated-link {
    position: relative;
    text-decoration: none;
    color: #3498db;
}
.animated-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #3498db;
    transition: width 0.3s ease;
}
.animated-link:hover::after { width: 100%; }

/* External link indicator */
a[href^="http"]::after {
    content: ' â†-';
    font-size: 0.8em;
}

Styling Lists

PropertyValuesDescription
list-style-typedisc | circle | square | decimal | lower-alpha | upper-roman | noneMarker type
list-style-positioninside | outsideMarker position relative to content
list-style-imageurl('icon.png')Custom image as marker
list-styleshorthandtype position image
List Styling - Custom Markers and Navigation
/* Remove default list styles */
ul, ol { list-style: none; padding: 0; margin: 0; }

/* Custom marker with ::before */
.custom-list li {
    padding-left: 1.5em;
    position: relative;
    margin-bottom: 8px;
}
.custom-list li::before {
    content: 'âœ"';
    position: absolute;
    left: 0;
    color: #2ecc71;
    font-weight: bold;
}

/* Horizontal navigation */
.nav-list {
    display: flex;
    gap: 0;
    list-style: none;
}
.nav-list li a {
    display: block;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    background: #2c3e50;
    transition: background 0.2s;
}
.nav-list li a:hover { background: #3498db; }

/* Ordered list styles */
ol.roman  { list-style-type: upper-roman; }
ol.alpha  { list-style-type: lower-alpha; }
ol.decimal { list-style-type: decimal-leading-zero; }

/* CSS counters for custom numbering */
.steps { counter-reset: step-counter; list-style: none; }
.steps li {
    counter-increment: step-counter;
    padding-left: 3em;
    position: relative;
    margin-bottom: 16px;
}
.steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    width: 2em;
    height: 2em;
    background: #3498db;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.