#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
CSS3 Fundamentals

Introduction CSS3

CSS (Cascading Style Sheets) is the language that controls how HTML looks: colours, fonts, spacing, layout and animation. HTML describes the structure and meaning of content, and CSS describes its presentation. "CSS3" is the common name for the modern generation of CSS, which added features like rounded corners, shadows, gradients, transitions, flexbox, grid and media queries.

Why CSS is kept separate from HTML

Early websites mixed styling into HTML with tags like font and attributes like bgcolor. Changing the look of a site meant editing every page. Separating style into CSS fixes that: one stylesheet can style hundreds of pages, and changing a single rule updates them all. It also keeps HTML clean and meaningful for screen readers and search engines.

Three ways to add CSS

  1. External stylesheet: a separate .css file linked from the head with a link tag. This is the standard approach for real sites because the browser can cache it.
  2. Internal styles: a style block in the head of one page. Fine for quick demos or page-specific rules.
  3. Inline styles: a style attribute on one element. Useful for quick tests, but hard to maintain and it overrides most other rules.
<!-- index.html -->
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <h2 class="title">Welcome</h2>
  <p>Styled by an external file.</p>
</body>

/* styles.css */
body {
  font-family: system-ui, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 16px;
}

.title {
  color: #4057d6;
  border-bottom: 2px solid currentColor;
}

What "cascading" actually means

Several rules can target the same element. The cascade is the set of rules the browser uses to decide which one wins. In short:

  • Importance: a declaration marked !important beats normal ones (use it sparingly).
  • Specificity: an ID selector beats a class, and a class beats a plain tag name.
  • Order: if specificity is equal, the rule that comes later wins.

Some properties, like color and font-family, are also inherited: set them on body and every child picks them up unless it overrides them. Others, like border and margin, are not inherited.

Highlights of modern CSS

Beyond colours and fonts, today's CSS handles things that once needed images or JavaScript: border-radius for rounded corners, box-shadow and gradients for depth, transition and @keyframes for animation, flexbox and grid for layout, media queries for responsive design, and custom properties (variables) like --brand: #4057d6; that you can reuse everywhere.

A beginner mistake worth avoiding

When a style does not apply, beginners often reach for !important or add inline styles. That usually hides the real cause, which is typically a typo in a selector, a wrong file path in the link tag, or another rule with higher specificity. Open the browser developer tools, inspect the element, and look at the Styles panel: it shows every rule that matches, which ones are crossed out, and why. Learning to read that panel early saves hours.

Takeaway: CSS styles your HTML from a separate file, rules are resolved by importance, specificity and order, and the browser's inspector is the fastest way to understand why a style does or does not apply.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course