CSS Topicwsie Programs

Practice quick CSS programs topic by topic with compact examples

1. Selectors

Program: Style by Class and ID

Goal: Apply different styles using class and id selectors.

.note { color: #0d6efd; font-weight: 600; }
#main-title { color: #dc3545; }
p { line-height: 1.7; }

2. Text Styling

Program: Beautiful Text Card

Goal: Improve readability with font, spacing, and shadow.

.article {
  font-family: "Segoe UI", sans-serif;
  font-size: 18px;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

3. Box Model

Program: Card with Margin, Border, Padding

Goal: Understand spacing using the CSS box model.

.card-box {
  margin: 20px;
  border: 2px solid #264de4;
  padding: 16px;
  border-radius: 10px;
}

4. Flex Layout

Program: Horizontal Menu Using Flexbox

Goal: Create evenly spaced menu items.

.menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

5. Form Styling

Program: Styled Input with Focus Effect

Goal: Make forms cleaner and user-friendly.

input[type="text"] {
  border: 1px solid #ced4da;
  padding: 10px 12px;
  border-radius: 6px;
}
input[type="text"]:focus {
  outline: none;
  border-color: #264de4;
  box-shadow: 0 0 0 3px rgba(38,77,228,0.2);
}

6. Responsive Design

Program: Responsive Two-Column Layout

Goal: Switch to single column on small screens.

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .grid {
    grid-template-columns: 1fr;
  }
}