🎉 Welcome to PyVerse! Start Learning Today

PYTHONDATA SCIENCE

Links, Lists, and Tables

CSS3 Course: Making Elements Beautiful and Functional

Introduction

Hello, aspiring web designers! 🎨 Today, we're diving into a fun and super useful part of CSS3—styling links, lists, and tables. These elements are crucial for shaping the way your website looks and feels! By the end of this lesson, you'll not only understand how to make your links pop, your lists tidy, and your tables elegant, but also gain the skills to impress your friends and family with your web design abilities!

Styling Links

Links are crucial for navigation on a website. They can be styled in various ways to stand out from the rest of the text.

Basic Link Styling

Here's how you can style links using CSS:

a { color: blue; /* Changes link color */ text-decoration: none; /* Removes the default underline */ } a:hover { color: red; /* Changes link color on hover */ text-decoration: underline; /* Adds underline on hover */ }

Example HTML:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Styling Links</title> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Welcome to PyVerse</h1> <p>Check out our <a href="#">amazing courses</a> and boost your skills!</p> </body> </html>

Styling Lists

Lists help organize information. You can style both ordered (<ol>) and unordered lists (<ul>) to make them visually appealing.

Basic List Styling

Here's how to make lists look fabulous:

ul { list-style-type: square; /* Changes bullet style */ padding-left: 20px; /* Adds space on the left */ } ol { list-style-type: upper-alpha; /* Uses A, B, C... for ordered lists */ } li { line-height: 1.6; /* Improves spacing between items */ margin: 5px 0; /* Adds space above and below list items */ }

Example HTML:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Styling Lists</title> <link rel="stylesheet" href="styles.css"> </head> <body> <h2>My Favorite Fruits</h2> <ul> <li>🍎 Apple</li> <li>🍌 Banana</li> <li>🍇 Grape</li> </ul> <h2>Top 3 Programming Languages</h2> <ol> <li>Python</li> <li>JavaScript</li> <li>Java</li> </ol> </body> </html>

Styling Tables

Tables are perfect for displaying data in a structured way. With CSS, you can make tables not only functional but also attractive!

Basic Table Styling

Here's how you can style a table:

table { border-collapse: collapse; /* Merges borders */ width: 100%; /* Makes the table full width */ } th, td { border: 1px solid black; /* Adds borders to cells */ padding: 10px; /* Adds space inside cells */ text-align: left; /* Aligns text to the left */ } th { background-color: #f2f2f2; /* Adds a background color to the header */ }

Example HTML:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Styling Tables</title> <link rel="stylesheet" href="styles.css"> </head> <body> <h2>Student Grades</h2> <table> <tr> <th>Name</th> <th>Math</th> <th>Science</th> </tr> <tr> <td>Alice</td> <td>90</td> <td>85</td> </tr> <tr> <td>Bob</td> <td>75</td> <td>80</td> </tr> </table> </body> </html>

Practical Exercise: Create Your Own Webpage! 

Now it's your turn to shine! Create a simple webpage that includes:

  • A section with styled links.
  • An unordered list of your favorite hobbies.
  • An ordered list showing your top 3 favorite songs.
  • A table listing 2 or 3 of your favorite movies with their year and rating.

Step-by-Step:

  • Create an HTML file and a separate CSS file.
  • Add the basic HTML structure.
  • Style the links, lists, and tables using the CSS examples you've learned.
  • Display the finished webpage in a browser and admire your handiwork!

Recap

Today, you've learned how to make your web pages vibrant by styling links, lists, and tables. By customizing appearances, you can guide users through your site effectively while enjoying the visual aspects of design. Remember, CSS is all about creativity, so don't be afraid to experiment with colors, sizes, and styles.

Happy coding! 

Loading quizzes...