Also Like

Module 7: Links and Tables

Module 7: Links and Tables Styling

Module 7: Links and Tables Styling

Master the art of styling interactive links and creating beautiful tables

Learning Outcomes

  • Understand different link states and how to style each
  • Master table styling and internal elements
  • Learn techniques for responsive tables
  • Apply advanced styling to tables using CSS
  • Accessibility standards for links and tables

Styling Links

HTML links have four distinct states that can be independently styled with CSS. This allows for enhanced user experience by changing appearance based on interaction.

Styling Tables

Tables should be both functional and visually appealing. Proper styling enhances readability and user experience.

Basic Table Styling

Product Category Price Stock
Premium Laptop Electronics $1,199 15
Wireless Headphones Audio $249 32
Smart Watch Wearables $399 8
Bluetooth Speaker Audio $129 21
/* Basic Table Styling */
.styled-table {
    width: 100%;
    border-collapse: collapse;
}

.styled-table th, 
.styled-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.styled-table th {
    background-color: var(--burgundy-main);
    color: white;
}

.styled-table tr:nth-child(even) {
    background-color: #fdf5f5;
}

.styled-table tr:hover {
    background-color: #fce9e9;
}

Responsive Table Techniques

Horizontal Scrolling

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

Wraps the table in a scrollable container for small screens.

Stacked Layout

@media (max-width: 600px) {
    .responsive-table td {
        display: block;
        text-align: right;
    }
    
    .responsive-table td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
    }
}

Converts table rows to stacked cards on mobile devices.

Interactive Playground

Experiment with link and table styling in this live code editor:

Code Editor
Live Preview

Knowledge Check

1. Which link state would you style to indicate when a user is clicking on a link?

2. What CSS property is essential for creating a zebra-striped table effect?

3. Which technique is NOT recommended for making tables responsive?

4. What is the correct order for styling link states?

5. Which CSS property removes the default underline from links?

© 2023 CSS Mastery Series | Designed for Web Developers