Category: CSS

  • CSS Best Practices

    Writing clean, maintainable, and optimized CSS is crucial for building scalable web projects. Implementing best practices such as structured naming conventions, modular CSS organization, and performance optimizations helps improve readability, reusability, and maintainability of your styles.

    Writing Maintainable CSS

    Maintainable CSS is easy to read, extend, and debug, especially in large projects where multiple developers might collaborate. Here are some key practices:

    1.1 Use Clear and Consistent Naming Conventions
    • Use descriptive class names that clearly indicate the element’s purpose or the style it represents.
    /* Bad Practice */
    .red { color: red; }
    
    /* Good Practice */
    .error-message { color: red; }
    • Stick to a consistent naming convention throughout your stylesheet. A common approach is to use lowercase and hyphen-separated names (kebab-case).
    .nav-bar { /* Kebab case */}
    1.2 Avoid Using IDs for Styling
    • Avoid using IDs for styling because they have high specificity, which makes them difficult to override.
    • Use classes instead, which are more flexible and reusable.
    /* Avoid this */
    #header {
      background-color: blue;
    }
    
    /* Use classes instead */
    .header {
      background-color: blue;
    }
    1.3 Use Shorthand Properties Where Possible
    • Use shorthand properties to reduce the amount of CSS code and make it more readable.
    /* Use shorthand for padding */
    .box {
      padding: 10px 20px; /* top-bottom 10px, left-right 20px */
    }
    
    /* Use shorthand for background */
    .background {
      background: url('image.jpg') no-repeat center center / cover;
    }
    1.4 Minimize the Use of !important
    • Avoid using !important unless absolutely necessary, as it increases specificity and makes styles hard to override or debug.

    BEM Methodology

    BEM (Block, Element, Modifier) is a popular naming convention that makes CSS more modular and reusable by structuring class names hierarchically. BEM class names consist of three parts:

    1. Block: The parent component (e.g., .card).
    2. Element: A child part of the block, represented by __ (e.g., .card__title).
    3. Modifier: A variant or state of the block or element, represented by -- (e.g., .card--highlighted).
     
    BEM Syntax:
    /* Block */
    .card {
      padding: 20px;
      background-color: #f4f4f4;
    }
    
    /* Element */
    .card__title {
      font-size: 24px;
      margin-bottom: 10px;
    }
    
    /* Modifier */
    .card--highlighted {
      border: 2px solid #ff5733;
    }
    Benefits of BEM:
    • Modularity: Each block, element, and modifier is a self-contained component, making it easy to reuse.
    • Clarity: The naming convention makes the relationships between elements clear, simplifying styling and maintenance.
     
    Example Usage of BEM:
    <div class="card card--highlighted">
      <h2 class="card__title">Card Title</h2>
      <p class="card__content">Card content goes here.</p>
    </div>

    In this example, card is the block, card__title and card__content are elements, and card--highlighted is a modifier that changes the card’s appearance.

    CSS Organization

    Properly organizing CSS helps maintain large stylesheets and prevents conflicts. Here are some best practices for structuring your CSS:

    3.1 Use a Modular Approach
    • Break down styles into small, manageable files and import them into a main stylesheet. This is especially important when using preprocessors like Sass.
    /* main.scss */
    @import 'base';
    @import 'components/card';
    @import 'layout/header';
    3.2 Order of Styles
    • Arrange styles in a logical order to improve readability. A common order is:
      1. Reset/Normalize: Resets default browser styles.
      2. Base/Global: Sets global styles (e.g., body, headings).
      3. Layout: Defines the structure of the page (e.g., grid, containers).
      4. Components: Styles reusable components (e.g., buttons, cards).
      5. Utilities: Contains utility classes for quick styling (e.g., .text-center).
    3.3 Use Comments and Section Headers
    • Use comments to section off different parts of your stylesheet, making it easier to navigate and understand.
    /* ========== Base Styles ========== */
    body {
      font-family: Arial, sans-serif;
    }
    
    /* ========== Components ========== */
    .button {
      padding: 10px 20px;
      background-color: #3498db;
      color: white;
    }

    Performance Optimization

    Optimizing CSS can improve page load times and user experience. Here are some key techniques:

    4.1 Minimize and Compress CSS Files
    • Minification: Remove whitespace, comments, and unnecessary characters from CSS files to reduce file size. Tools like cssnano and postcss can automatically minify CSS files.
    npm install cssnano --save-dev
    • Compression: Use Gzip or Brotli compression on the server to further reduce file size during transfer.
    4.2 Use Fewer Selectors
    • Avoid overly complex selectors that require a lot of processing. Prefer using classes for styling as they are less computationally intensive.
    /* Avoid this */
    div > ul > li > a {
      color: blue;
    }
    
    /* Prefer this */
    .nav-link {
      color: blue;
    }
    4.3 Use CSS Shorthand
    • CSS shorthand properties reduce the size of your stylesheets and speed up the rendering process.
    /* Shorthand for padding */
    padding: 10px 20px;
    
    /* Shorthand for background */
    background: #ff5733 url('image.jpg') no-repeat center center / cover;
    4.4 Lazy Load Non-Critical CSS
    • For large projects, consider splitting your CSS into critical (above-the-fold) and non-critical (below-the-fold) styles. Load critical styles inline in the <head> and defer non-critical styles to improve initial render times.
    <link rel="stylesheet" href="main.css" media="print" onload="this.media='all'">
    4.5 Use Modern Layouts (Flexbox, Grid) Over Floats
    • Use modern CSS layouts like Flexbox and Grid for responsive design and layout structure. These methods are more performant and flexible than older techniques like floats.
    .container {
      display: flex;
      justify-content: space-between;
    }

    Summary

    Writing maintainable CSS involves using clear naming conventions, avoiding IDs for styling, and keeping styles concise and organized. BEM methodology helps create modular and reusable CSS by using a structured naming convention for blocks, elements, and modifiers. Organizing CSS into sections, using a modular approach, and ordering styles logically are key to managing large stylesheets. Performance optimization techniques, such as minifying CSS, using shorthand properties, and lazy loading, ensure that your website loads faster and delivers a smooth user experience. By following these best practices, you can build robust, maintainable, and efficient styles for your projects.

  • Advanced CSS

    Advanced CSS techniques allow you to build more maintainable, flexible, and sophisticated web designs. Using features like CSS variables, functions, preprocessors, and frameworks can significantly improve your workflow and the quality of your designs.

    CSS Variables

    CSS Variables (also known as custom properties) allow you to store values that you can reuse throughout your stylesheet. This improves maintainability and enables easier theming.

    Syntax of CSS Variables:
    :root {
      --main-color: #06c;
    }
    .element {
      color: var(--main-color);
    }
    • :root: A pseudo-class that selects the highest-level parent element in the document, typically used to define global variables.
    • --variable-name: Defines a CSS variable. Custom properties must begin with --.
    • var(): The function used to call a CSS variable.
    Example: Changing Themes Using CSS Variables
    :root {
      --background-color: white;
      --text-color: black;
    }
    
    .dark-theme {
      --background-color: black;
      --text-color: white;
    }
    
    body {
      background-color: var(--background-color);
      color: var(--text-color);
    }

    By adding the dark-theme class to the body, you can switch to a dark mode theme, demonstrating how CSS variables can simplify theming.

    CSS Functions

    CSS functions like calc()min()max(), and clamp() provide dynamic ways to calculate values directly in CSS.

    2.1 calc() Function

    The calc() function performs mathematical operations to determine CSS property values, allowing for more flexible layouts.

    .container {
      width: calc(100% - 20px);
      padding: calc(10px + 2%);
    }
    • You can use basic arithmetic operators: +-*, and /.
    • Useful for responsive design and spacing.
     
    2.2 min() and max() Functions
    • min(): Returns the smallest value from a list of values.
    • max(): Returns the largest value from a list of values.
    .box {
      width: min(80%, 400px); /* The width will be 80% of the container but no more than 400px */
    }
    
    .content {
      padding: max(20px, 5%); /* Padding will be at least 20px, but will grow to 5% if larger */
    }
    2.3 clamp() Function

    The clamp() function sets a value within a defined range, specifying a minimum, preferred, and maximum value.

    .text {
      font-size: clamp(16px, 2vw, 24px); /* The font size will be 16px at minimum, scale with viewport width, but will not exceed 24px */
    }
    • clamp(min, preferred, max): Ensures the value stays between the min and max while allowing dynamic resizing in between.

    CSS Preprocessors (Sass, Less)

    CSS Preprocessors like Sass and Less extend CSS by adding features such as variables, nesting, mixins, and more, making your stylesheets more powerful and easier to maintain.

    3.1 Sass (Syntactically Awesome Style Sheets)

    Sass is one of the most popular CSS preprocessors that adds advanced features to CSS.

    Variables in Sass:
    $primary-color: #3498db;
    $font-size-large: 24px;
    
    h1 {
      color: $primary-color;
      font-size: $font-size-large;
    }
    Nesting in Sass:
    .nav {
      background: #333;
    
      ul {
        list-style: none;
    
        li {
          display: inline-block;
          padding: 10px;
    
          a {
            color: white;
            text-decoration: none;
          }
        }
      }
    }
    Mixins in Sass:

    Mixins allow you to create reusable blocks of styles.

    @mixin border-radius($radius) {
      border-radius: $radius;
    }
    
    .box {
      @include border-radius(10px);
    }
    3.2 Less (Leaner Style Sheets)

    Less is another popular preprocessor with similar features to Sass but uses slightly different syntax.

    Variables in Less:
    @primary-color: #3498db;
    @font-size-large: 24px;
    
    h1 {
      color: @primary-color;
      font-size: @font-size-large;
    }
    Mixins in Less:
    .border-radius(@radius) {
      border-radius: @radius;
    }
    
    .box {
      .border-radius(10px);
    }
    Using CSS Preprocessors:

    To use Sass or Less in your projects, you need to install them via npm or other package managers and compile .scss or .less files into standard .css files.

    # For Sass
    npm install -g sass
    sass input.scss output.css
    
    # For Less
    npm install -g less
    lessc input.less output.css

    CSS Frameworks

    CSS Frameworks provide pre-built components, styles, and utilities to speed up the design process and create responsive layouts with minimal custom CSS.

    4.1 Bootstrap

    Bootstrap is a widely-used, responsive CSS framework that offers a collection of components, grid systems, utilities, and JavaScript plugins.

    Features of Bootstrap:
    • Grid System: A 12-column responsive grid system for creating flexible layouts.
    <div class="container">
      <div class="row">
        <div class="col-md-6">Column 1</div>
        <div class="col-md-6">Column 2</div>
      </div>
    </div>
    • Components: Pre-styled components like buttons, forms, modals, navigation bars, and more.
    <button class="btn btn-primary">Primary Button</button>
    • Utilities: Classes for spacing, text alignment, backgrounds, borders, and more.
    <div class="p-3 mb-2 bg-success text-white">Success Background</div>
    4.2 Tailwind CSS

    Tailwind CSS is a utility-first CSS framework that provides low-level utility classes for building custom designs directly in your HTML.

    Features of Tailwind CSS:
    • Utility Classes: Offers a wide range of utility classes for spacing, sizing, colors, borders, flexbox, grid, and more.
    <div class="flex items-center justify-center h-screen">
      <button class="bg-blue-500 text-white font-bold py-2 px-4 rounded">Click Me</button>
    </div>
    • Customization: You can extend or customize the default design by editing the tailwind.config.js file.
    // tailwind.config.js
    module.exports = {
      theme: {
        extend: {
          colors: {
            'custom-blue': '#3490dc',
          },
        },
      },
    };
    • Responsive Design: Built-in responsive utilities (sm:md:lg:xl:) make creating layouts for different screen sizes effortless.
    <div class="p-4 sm:p-8 md:p-12 lg:p-16">
      Responsive Padding
    </div>
    Using Tailwind CSS:

    You can install Tailwind via npm and use it with your project:

    npm install tailwindcss
    npx tailwindcss init

    Summary

    Advanced CSS techniques like CSS variables and functions (calc()min()max()clamp()) provide powerful ways to create flexible, dynamic, and maintainable styles. CSS preprocessors (Sass, Less) introduce variables, nesting, mixins, and more to make complex styling easier. Meanwhile, CSS frameworks like Bootstrap and Tailwind CSS offer a range of pre-styled components and utility classes that significantly speed up the development process. By mastering these tools, you can build more sophisticated and responsive web designs efficiently.

  • CSS Transitions and Animations

    CSS transitions and animations add dynamic, engaging elements to web pages, allowing for changes in property values over a set period. They enhance user experience and provide visual feedback, creating a more interactive and polished website.

    CSS Transitions

    CSS transitions allow you to change the properties of an element smoothly over a specified duration. With transitions, you can animate properties like color, size, position, and opacity when an element’s state changes (e.g., hover, focus, click).

    Basic Syntax:

    .selector {
      transition: property duration timing-function delay;
    }
    • property: The CSS property you want to animate (e.g., widthbackground-color). Use all to animate all properties.
    • duration: The time the transition takes, specified in seconds (s) or milliseconds (ms).
    • timing-function: Defines the speed curve of the transition. Common values: easelinearease-inease-outease-in-out.
    • delay: Specifies a delay before the transition starts.
     
    Example: Simple Hover Transition
    .button {
      background-color: blue;
      color: white;
      padding: 10px 20px;
      transition: background-color 0.3s ease, transform 0.3s ease;
    }
    
    .button:hover {
      background-color: green;
      transform: scale(1.1);
    }

    In this example, when the button is hovered over, its background color changes from blue to green and scales up slightly over 0.3s with an ease transition.

    Multiple Transitions:

    You can animate multiple properties by separating them with commas.

    .box {
      width: 100px;
      height: 100px;
      background-color: red;
      transition: width 0.5s, height 0.5s, background-color 1s;
    }
    
    .box:hover {
      width: 200px;
      height: 200px;
      background-color: blue;
    }

    CSS Animations

    CSS animations allow you to create complex sequences of movements and transformations using keyframes. Unlike transitions, animations can be repeated indefinitely and can change properties multiple times during the animation.

    Basic Syntax:
    .selector {
      animation: name duration timing-function delay iteration-count direction;
    }
    • name: The name of the animation (defined using @keyframes).
    • duration: How long the animation takes to complete one cycle.
    • timing-function: The speed curve of the animation (e.g., easelinear).
    • delay: Specifies a delay before the animation starts.
    • iteration-count: The number of times the animation should run (e.g., infinite13).
    • direction: Defines whether the animation should play forwards, backwards, or alternate. Common values: normalreversealternate.
    Example: Simple Animation
    @keyframes slide {
      0% {
        transform: translateX(0);
      }
      50% {
        transform: translateX(100px);
      }
      100% {
        transform: translateX(0);
      }
    }
    
    .box {
      width: 50px;
      height: 50px;
      background-color: orange;
      animation: slide 2s ease-in-out infinite;
    }

    Here, the .box element moves horizontally (left to right and back) over 2s in an infinite loop using the slide animation.

    Keyframes

    Keyframes define the states of an element during an animation. You use the @keyframes rule to specify the properties’ values at different points during the animation’s duration.

    Basic Keyframes Syntax:
    @keyframes animation-name {
      /* Define the animation states */
      0% {
        /* Starting state */
      }
      50% {
        /* Midway state */
      }
      100% {
        /* Ending state */
      }
    }

    Example: Color Change Animation

    @keyframes colorChange {
      0% {
        background-color: red;
      }
      50% {
        background-color: yellow;
      }
      100% {
        background-color: green;
      }
    }
    
    .color-box {
      width: 100px;
      height: 100px;
      animation: colorChange 4s linear infinite;
    }

    This animation changes the background color of .color-box from red to yellow to green over 4s.

    Using from and to:

    You can use from and to as shorthand for 0% and 100%.

    @keyframes fadeIn {
      from {
        opacity: 0;
      }
      to {
        opacity: 1;
      }
    }

    Transformations

    CSS transformations allow you to rotate, scale, skew, or move elements without disrupting the normal document flow. Commonly used with transitions and animations, the transform property can create a wide range of effects.

    Common Transform Functions:
    • translate(x, y): Moves an element along the X and Y axes.
    .move {
      transform: translate(50px, 100px);
    }
    • scale(x, y): Resizes an element. Values greater than 1 enlarge the element, while values between 0 and 1 shrink it.
    .zoom {
      transform: scale(1.5); /* Enlarges the element to 150% of its original size */
    }
    • rotate(angle): Rotates an element by a specified angle (in degrees).
    .rotate {
      transform: rotate(45deg);
    }
    • skew(x, y): Skews an element along the X and Y axes.
    .rotate {
      transform: rotate(45deg);
    }
    • transform-origin: Sets the point from which the transformation is applied (e.g., centertop left).
    .rotate-origin {
      transform: rotate(45deg);
      transform-origin: top left;
    }
    Combining Transformations:

    You can combine multiple transformations by separating them with a space.

    .combo {
      transform: translate(50px, 100px) scale(1.2) rotate(30deg);
    }

    Summary

    CSS transitions and animations enhance user experience by allowing smooth changes in element properties. Transitions are best suited for simple, state-based changes (e.g., hover effects), while animations provide more complex, multi-step movements through keyframesTransformations are the building blocks for dynamic effects, enabling elements to move, rotate, scale, and skew. Together, these tools give you powerful control over how elements behave and interact on your website, making it more engaging and visually appealing.

  • CSS Units

    CSS units are used to define the size of various elements on a webpage, such as font size, width, height, margin, padding, and more. Understanding both absolute and relative units is essential for creating flexible and responsive designs.

    Absolute Units

    Absolute units have a fixed size regardless of the context or device screen size. They are best suited for print design but can be used in web design in certain scenarios where precise control is needed. However, they are not recommended for responsive design as they do not scale well with different devices.

    Common Absolute Units:
    1. Pixels (px):
      • The most commonly used unit in web design.
      • One pixel is a single dot on the screen. The size of a pixel can vary depending on the device’s resolution.
      • Great for precise, fixed measurements.
    h1 {
      font-size: 24px;
    }
    • 2. Points (pt):
      • Traditionally used in print media.
      • 1 point is equal to 1/72 of an inch. Primarily used for defining font sizes in print styles.
    p {
      font-size: 12pt;
    }
    • 3. Centimeters (cm) and Inches (in):
      • Physical units of measurement.
      • 1 inch (in) = 2.54 centimeters (cm).
      • Rarely used in web design since the exact size on screen can vary depending on the device.
    .box {
      width: 5cm;
      height: 2in;
    }

    Note: Absolute units like ptcm, and in are more suited for printed media rather than digital screens.

    Relative Units

    Relative units are flexible and scale with the size of the viewport or parent elements. They are essential for building responsive layouts that adapt to different screen sizes and user preferences.

    Common Relative Units:
    1. em:
      • Relative to the font size of the parent element.
      • If an element’s parent has a font size of 16px, 1em would be equal to 16px.
      • Useful for setting relative sizing that scales based on the context.
    /* Assuming the parent has a font-size of 16px */
    p {
      font-size: 2em; /* This will be 32px (2 * 16px) */
    }
      • Nesting with em: Be cautious when using nested elements, as the em unit can accumulate changes from its ancestors.
    • 2. rem (Root em):
      • Relative to the font size of the root element (usually the <html> element).
      • Provides a consistent sizing mechanism that is not affected by nested parent elements.
      • Ideal for defining sizes in a way that scales uniformly across the document.
    html {
      font-size: 16px; /* 1rem = 16px */
    }
    
    h1 {
      font-size: 2rem; /* This will be 32px (2 * 16px) */
    }
      • Why Use rem?: Using rem ensures that font sizes and spacing scale consistently, making it easier to implement responsive designs.
    • 3. Percentage (%):
      • Relative to the size of the parent element.
      • Commonly used for width, height, margin, padding, and font sizes.
    .container {
      width: 80%; /* Takes 80% of the parent element's width */
    }
    
    .child {
      font-size: 150%; /* 150% of the parent's font size */
    }
    • 4. Viewport Width (vw) and Viewport Height (vh):
      • Relative to the size of the viewport (browser window).
      • 1vw equals 1% of the viewport’s width, and 1vh equals 1% of the viewport’s height.
      • Useful for creating layouts that adjust to the size of the device’s screen.
    .full-screen {
      width: 100vw; /* Full width of the viewport */
      height: 100vh; /* Full height of the viewport */
    }
    
    .responsive-text {
      font-size: 5vw; /* Font size scales with the viewport's width */
    }

    Choosing Between Absolute and Relative Units

    • Use Absolute Units (pxpt, etc.) when you need:
      • Exact, pixel-perfect measurements.
      • Fixed-sized elements that do not need to respond to changes in the viewport.
      • Print stylesheets.
    • Use Relative Units (emrem%vwvh) when you want:
      • Flexible and responsive layouts.
      • Elements that scale based on the viewport size or parent elements.
      • Consistent spacing and font sizes that adjust based on the user’s settings.

    Summary

    CSS units define the size and spacing of elements on a webpage. Absolute units like pxptcm, and in are fixed and useful when you need precise, unchanging sizes. In contrast, relative units like emrem%vw, and vh are flexible, adapting to the size of the parent element, the root element, or the viewport. They are crucial for creating responsive, fluid designs that adjust to different devices and screen sizes. Understanding when and how to use these units is essential for building modern, accessible web layouts.

  • Responsive Web Design

    Responsive Web Design (RWD) is a web development approach that ensures a website looks and works well on devices of all sizes, from large desktop monitors to small mobile screens. This approach involves using flexible grids, responsive images, and media queries to adapt the layout and content to various viewport sizes.

    Media Queries

    Media queries are a CSS feature that allows you to apply styles based on the characteristics of the user’s device, such as screen width, height, orientation, and resolution. They are the backbone of responsive design, enabling you to adjust styles for different devices and screen sizes.

    Basic Syntax of Media Queries:
    @media (max-width: 768px) {
      /* Styles for screens with a width of 768px or less (e.g., tablets and mobile devices) */
      body {
        background-color: lightblue;
      }
    }
    
    @media (min-width: 769px) and (max-width: 1200px) {
      /* Styles for screens between 769px and 1200px (e.g., tablets and small laptops) */
      body {
        background-color: lightgreen;
      }
    }
    
    @media (orientation: landscape) {
      /* Styles for screens in landscape orientation */
      body {
        background-color: lightcoral;
      }
    }
    Common Media Query Breakpoints:

    Breakpoints are specific screen widths at which the layout of the website changes to accommodate different devices. Here are some common breakpoints used in responsive design:

    • Small devices (phones)max-width: 600px
    • Medium devices (tablets)min-width: 601px and max-width: 768px
    • Large devices (desktops)min-width: 769px and max-width: 1200px
    • Extra-large devices (large desktops)min-width: 1201px
     
    Example of Using Media Queries for Layout:
    /* Default styles for desktop */
    .container {
      display: flex;
      flex-direction: row;
    }
    
    /* Mobile styles */
    @media (max-width: 600px) {
      .container {
        flex-direction: column;
      }
    }

    In this example, the .container element switches from a row layout to a column layout on screens smaller than 600px.

    Responsive Images

    Responsive images automatically adjust their size and resolution to fit different devices and screen sizes. This not only improves the visual quality of the website but also optimizes performance by reducing image loading times on smaller screens.

    2.1 Using the srcset Attribute:

    The srcset attribute allows the browser to choose the most appropriate image size based on the device’s screen width.

    <img decoding="async" src="image-small.jpg"
         srcset="image-small.jpg 600w, image-medium.jpg 1200w, image-large.jpg 2000w"
         sizes="(max-width: 600px) 100vw, (max-width: 1200px) 50vw, 33vw"
         alt="Sample Image">
    • srcset: Lists the image files with their respective widths.
    • sizes: Defines the display width for each condition. Here, 100vw means 100% of the viewport width.

    2.2 Using the <picture> Element for Art Direction:

    The <picture> element provides greater control over which image to display in different scenarios, such as changing the image based on screen size or orientation.

    <picture>
      <source media="(max-width: 600px)" srcset="image-small.jpg">
      <source media="(max-width: 1200px)" srcset="image-medium.jpg">
      <img decoding="async" src="image-large.jpg" alt="Sample Image">
    </picture>

    In this example, the browser selects the appropriate image based on the specified media queries.

    2.3 Lazy Loading Images:

    The loading attribute delays the loading of images until they are visible in the viewport, improving initial page load times.

    <img decoding="async" src="image.jpg" alt="Lazy Loaded Image" loading="lazy">

    Mobile-first Design

    Mobile-first design is a strategy that involves designing and developing a website for mobile devices first and then gradually adding more complex layouts for larger screens. This approach prioritizes mobile users and helps create a responsive, optimized experience for all devices.

    Why Mobile-First?
    • Mobile Traffic: A significant portion of web traffic comes from mobile devices, so optimizing for smaller screens is essential.
    • Simpler Design: Starting with a simple design for mobile screens helps focus on core content and usability.
    • Performance: Mobile-first design encourages the use of lightweight resources, improving page load times on slower mobile networks.

    Mobile-First CSS Example:
    /* Base styles for mobile devices */
    .container {
      display: block;
      padding: 10px;
      font-size: 16px;
    }
    
    /* Styles for larger screens */
    @media (min-width: 768px) {
      .container {
        display: flex;
        padding: 20px;
        font-size: 18px;
      }
    }

    In this example, the default styling is set for mobile devices. Additional styles are then added using a media query for screens larger than 768px.

    Viewport Meta Tag

    The viewport meta tag is crucial for responsive web design. It controls the layout on mobile browsers by specifying how a web page should be scaled and displayed on different screen sizes. Without it, websites may appear zoomed-out on mobile devices, requiring users to pinch-to-zoom to read content.

    Basic Viewport Meta Tag:
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    Explanation of Attributes:
    • width=device-width: Sets the width of the viewport to match the width of the device. This allows the layout to adjust based on the device’s screen size.
    • initial-scale=1.0: Sets the initial zoom level when the page is first loaded. A value of 1.0 means no zoom.
    Other Optional Attributes:
    • maximum-scale: Limits how much a user can zoom in.
    • user-scalable: Allows (yes) or disallows (no) user zooming.
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    This tag prevents users from zooming in, which can be useful for specific web applications.

    Summary

    Responsive Web Design (RWD) is an essential practice that ensures your website provides a seamless experience across all devices. Media queries allow you to apply styles based on device characteristics, helping you create layouts that adapt to different screen sizes. Responsive images optimize visual content for various devices, improving both quality and performance. Mobile-first design emphasizes building a solid foundation for mobile users before adding enhancements for larger screens. Lastly, the viewport meta tag is crucial for controlling how your website is displayed on mobile devices, ensuring the content scales correctly. By mastering these techniques, you can create a flexible and user-friendly website that looks great on any device.

  • CSS Layout

    CSS provides various properties to control the layout of elements on a web page. Understanding how to use these properties effectively is crucial for creating complex, responsive layouts that work across different devices and screen sizes.

    Display Property

    The display property defines how an element is displayed on the page. It’s one of the fundamental properties for layout design.

    Common Display Values:
    • block: The element takes up the full width available, starting on a new line.
    p {
      display: block;
    }
    • inline: The element takes up only as much width as necessary and does not start on a new line.
    p {
      display: block;
    }
    • inline-block: The element flows inline but can have width and height set.
    .inline-box {
      display: inline-block;
      width: 100px;
      height: 50px;
    }
    • none: The element is not displayed on the page (hidden).
    .hidden {
      display: none;
    }
    • flex: Enables a flexible layout using the Flexbox model.
    .container {
      display: flex;
    }
    • grid: Enables a grid-based layout.
    .grid-container {
      display: grid;
    }

    Positioning (Static, Relative, Absolute, Fixed, Sticky)

    The position property specifies the positioning method of an element. The type of positioning affects how an element is placed in the document flow.

    CSS Position
    2.1 Static Positioning (static)
    • Default value. The element is positioned according to the normal flow of the document.
    • The toprightbottom, and left properties have no effect.
    .element {
      position: static;
    }
    2.2 Relative Positioning (relative)
    • The element is positioned relative to its original position in the document flow.
    • toprightbottom, and left properties move the element from its normal position.
    .element {
      position: relative;
      top: 10px; /* Moves the element 10px down from its original position */
      left: 20px; /* Moves the element 20px to the right */
    }
    2.3 Absolute Positioning (absolute)
    • The element is positioned relative to its closest positioned ancestor (relativeabsolutefixed, or sticky). If no such ancestor exists, it is positioned relative to the viewport.
    • The element is removed from the normal document flow.
    .element {
      position: absolute;
      top: 0;
      right: 0;
    }
    2.4 Fixed Positioning (fixed)
    • The element is positioned relative to the viewport, meaning it stays in place even when the page is scrolled.
    • The element is removed from the normal document flow.
    .element {
      position: fixed;
      bottom: 0;
      right: 0;
    }
    2.5 Sticky Positioning (sticky)
    • The element toggles between relative and fixed positioning based on the user’s scroll position.
    • It “sticks” to a defined position (toprightbottomleft) when the element reaches a specified scroll point.
    .element {
      position: sticky;
      top: 20px; /* The element sticks 20px from the top of the viewport */
    }

    Flexbox

    Flex-wrap

    Flexbox (Flexible Box Layout) is a one-dimensional layout model that allows you to create flexible and responsive layouts easily. It’s particularly useful for aligning items along a row or column and distributing space within a container.

    3.1 Basic Flexbox Properties:
    • display: flex;: Converts a container into a flex container.
    .container {
      display: flex;
    }
    • flex-direction: Defines the direction in which flex items are placed. Values: rowrow-reversecolumncolumn-reverse.
    .container {
      flex-direction: row;
    }
    • justify-content: Aligns items along the main axis (horizontally in a row, vertically in a column). Values: flex-startflex-endcenterspace-betweenspace-around.
    .container {
      justify-content: center;
    }
    • align-items: Aligns items along the cross axis (vertically in a row, horizontally in a column). Values: flex-startflex-endcenterstretch.
    .container {
      align-items: center;
    }
    • flex-wrap: Controls whether items wrap onto multiple lines. Values: nowrapwrapwrap-reverse.
    .container {
      flex-wrap: wrap;
    }
    3.2 Flex Item Properties:
    • flex: A shorthand for flex-growflex-shrink, and flex-basis. It defines how a flex item will grow or shrink to fit the space in the flex container.
    .item {
      flex: 1; /* Items will equally share the available space */
    }

    CSS Grid

    CSS Grid Layout is a two-dimensional layout system that allows you to create complex layouts with rows and columns.

    CSS Grid
    4.1 Basic Grid Properties:
    • display: grid;: Converts an element into a grid container.
    .grid-container {
      display: grid;
    }
    • grid-template-columns and grid-template-rows: Defines the size and number of columns and rows.
    .grid-container {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr; /* Creates three equal columns */
      grid-template-rows: 100px 200px; /* Creates two rows with specified heights */
    }
    • grid-gap: Adds spacing between grid items.
    .grid-container {
      grid-gap: 10px;
    }
    4.2 Placing Items in the Grid:
    • grid-column and grid-row: Specifies the position of an item within the grid.
    .grid-item {
      grid-column: 1 / 3; /* Spans from column 1 to 3 */
      grid-row: 1 / 2; /* Spans from row 1 to 2 */
    }

    Float and Clear

    Floats are a legacy method for creating layouts. While not as commonly used today due to Flexbox and Grid, floats can still be useful for text wrapping and other specific scenarios.

    5.1 Float Property:
    • float: Moves an element to the left or right, allowing text and inline elements to wrap around it.
    .image {
      float: left;
      margin-right: 10px;
    }
    5.2 Clear Property:
    • clear: Prevents elements from wrapping around a floated element. Values: leftrightboth.
    .clearfix {
      clear: both;
    }
    5.3 The Clearfix Hack:

    Floated elements are removed from the normal document flow, which can cause parent containers to collapse. The clearfix hack is used to force the parent to contain its floated children.

    .container::after {
      content: "";
      display: table;
      clear: both;
    }

    Summary

    CSS layout properties provide powerful ways to position, align, and distribute space within elements on a web page. The display property determines how elements are rendered, while position allows for various placement strategies such as static, relative, absolute, fixed, and sticky. Flexbox offers a one-dimensional layout system ideal for creating responsive rows or columns, and CSS Grid enables more complex, two-dimensional layouts. While float and clear are older layout methods, they can still be useful in certain situations. Mastering these properties is essential for designing flexible, responsive, and visually appealing web layouts.

  • CSS Properties and Values

    CSS properties define how HTML elements are displayed, allowing you to control aspects like text styling, font, color, spacing, backgrounds, and borders. Knowing how to use these properties effectively is key to creating visually appealing and user-friendly websites. Here’s an overview of some essential CSS properties and values.

    Text Properties

    Text properties control the appearance of text, including alignment, spacing, decoration, and transformation.

    Common Text Properties:

    • color: Changes the text color.
    p {
      color: #333;
    }
    • text-align: Aligns the text within its container. Common values: leftrightcenterjustify.
    h1 {
      text-align: center;
    }
    • text-decoration: Adds decoration to text (underline, overline, line-through).
    a {
      text-decoration: none;
    }
    • text-transform: Changes the case of text. Values: uppercaselowercasecapitalize.
    h2 {
      text-transform: uppercase;
    }
    • line-height: Sets the height of lines of text, helping control the spacing between lines.
    p {
      line-height: 1.5;
    }
    • letter-spacing: Adjusts the space between characters.
    h1 {
      letter-spacing: 2px;
    }

    Font Properties

    Font properties allow you to change the typeface, size, style, and weight of text.

    Common Font Properties:
    • font-family: Sets the typeface for the text. It’s best to provide a fallback list in case the first font is not available.
    body {
      font-family: Arial, Helvetica, sans-serif;
    }
    • font-size: Sets the size of the text. Can be specified in various units, such as pxem%rem.
    p {
      font-size: 16px;
    }
    • font-style: Sets the style of the font. Values: normalitalicoblique.
    em {
      font-style: italic;
    }
    • font-weight: Sets the thickness of the font. Values can be numeric (100–900) or keywords (normalbold).
    h1 {
      font-weight: bold;
    }
    • font-variant: Controls the variant of the font, such as small-caps.
    p {
      font-variant: small-caps;
    }

    Color Properties

    Color properties control the colors of text, backgrounds, borders, and other elements. CSS supports color names, hexadecimal, RGB, RGBA, HSL, and HSLA values.

    Common Color Properties:
    • color: Sets the text color.
    h1 {
      color: #ff5733;
    }
    • background-color: Sets the background color of an element.
    body {
      background-color: #f0f0f0;
    }
    • opacity: Sets the opacity level of an element, ranging from 0 (completely transparent) to 1 (completely opaque).
    .overlay {
      background-color: black;
      opacity: 0.5;
    }

    Background Properties

    Background properties control the background styling of elements, including images, colors, and positioning.

    Common Background Properties:
    • background-image: Sets an image as the background of an element.
    body {
      background-image: url('background.jpg');
    }
    • background-repeat: Specifies whether and how a background image repeats. Values: repeatno-repeatrepeat-xrepeat-y.
    body {
      background-image: url('background.jpg');
      background-repeat: no-repeat;
    }
    • background-position: Sets the initial position of a background image. Common values: leftcenterrighttopbottom.
    body {
      background-image: url('background.jpg');
      background-position: center;
    }
    • background-size: Adjusts the size of the background image. Values: covercontain, specific dimensions (e.g., 100px 200px).
    body {
      background-image: url('background.jpg');
      background-size: cover;
    }
    • background-color: Sets the background color of an element (as mentioned above).

    Border Properties

    Border properties define the border around elements, including color, width, and style.

    Common Border Properties:
    • border: A shorthand property for setting border width, style, and color.
    div {
      border: 2px solid #333;
    }
    • border-width: Specifies the width of the border.
    p {
      border-width: 1px;
    }
    • border-style: Defines the style of the border. Values: soliddasheddotteddoublegrooveridgeinsetoutset.
    div {
      border-style: dashed;
    }
    • border-color: Sets the color of the border.
    h2 {
      border-color: red;
    }
    • border-radius: Creates rounded corners.
    button {
      border-radius: 5px;
    }

    Margin and Padding

    Margins and padding are used to create space around elements, both inside (padding) and outside (margin) their borders.

    6.1 Margin
    • margin: Sets the outer space around an element. It can be specified as a single value (applies to all sides) or individual values for top, right, bottom, and left.
    .container {
      margin: 20px;
    }
    
    .box {
      margin: 10px 15px 20px 25px; /* top right bottom left */
    }
    6.2 Padding
    • padding: Sets the inner space between an element’s content and its border. Like margin, it can accept one, two, three, or four values.
    .content {
      padding: 10px;
    }
    
    .text {
      padding: 5px 10px 15px 20px; /* top right bottom left */
    }

    Box Model

    Css Box Model

    The CSS Box Model is a crucial concept in web design, describing how elements are structured and how they occupy space on the page. Each element is essentially a rectangular box comprising four parts:

    1. Content: The inner content of the element, such as text or an image.
    2. Padding: The space between the content and the border.
    3. Border: The outline around the padding (or content if padding is not set).
    4. Margin: The outermost space that separates the element from other elements.
    Example: Visualizing the Box Model
    .box {
      width: 200px;
      padding: 20px;
      border: 5px solid black;
      margin: 10px;
    }
    • Width: 200px.
    • Padding: Adds 20px of space around the content, increasing the total box size.
    • Border: Adds a 5px border around the padding.
    • Margin: Adds 10px of space outside the border, affecting the element’s position relative to other elements.

    Total Width = content width + padding + border + margin
    = 200px + (20px * 2) + (5px * 2) + (10px * 2)
    = 290px.

    Using box-sizing to Control the Box Model

    The box-sizing property changes how the total width and height of an element are calculated. Setting box-sizing: border-box; includes the padding and border in the total width and height, making layout design easier.

    .box {
      box-sizing: border-box;
      width: 200px; /* Total width includes padding and border */
      padding: 20px;
      border: 5px solid black;
    }

    Summary

    CSS properties allow you to control the appearance and layout of elements on a webpage. Text properties style text, while font properties change typeface characteristics. Color properties define text, background, and border colors, enhancing visual aesthetics. Background properties add colors or images to elements, and border properties outline elements with various styles. Margin and padding provide spacing around and within elements, forming part of the box model—a fundamental concept in CSS for understanding element layout. Mastering these properties is essential for creating well-structured, attractive, and responsive web designs.

  • CSS Selectors

    CSS selectors are patterns used to target and style specific HTML elements. They allow you to apply styles to elements based on various conditions, such as element type, class, ID, attributes, and more. Understanding selectors is essential for effectively styling web pages.

    Basic Selectors

    Basic selectors target elements based on their name, class, ID, or other straightforward characteristics.

    1.1 Element (Type) Selector

    Selects elements by their tag name.

    /* Selects all <p> elements */
    p {
      color: blue;
    }
    1.2 Class Selector

    Selects elements based on their class attribute. Classes are defined with a dot (.) followed by the class name.

    /* Selects all elements with the class "highlight" */
    .highlight {
      background-color: yellow;
    }
    1.3 ID Selector

    Selects an element based on its unique ID attribute. IDs are defined with a hash (#) followed by the ID name.

    /* Selects the element with the ID "header" */
    #header {
      font-size: 24px;
    }

    Note: IDs should be unique within a page, while classes can be reused across multiple elements.

    1.4 Universal Selector

    Selects all elements on the page.

    /* Applies margin and padding reset to all elements */
    * {
      margin: 0;
      padding: 0;
    }

    Grouping Selectors

    Grouping selectors allows you to apply the same styles to multiple elements at once, reducing redundancy in your CSS code.

    /* Applies the same style to all <h1> and <h2> elements */
    h1, h2 {
      color: darkgreen;
      font-family: Arial, sans-serif;
    }

    Attribute Selectors

    Attribute selectors target elements based on the presence or value of specific attributes.

    3.1 Basic Attribute Selector

    Selects elements with a specified attribute.

    /* Selects all <input> elements with a "type" attribute */
    input[type] {
      border: 1px solid #ccc;
    }
    3.2 Attribute Value Selector

    Selects elements with an attribute of a specific value.

    /* Selects all <input> elements where type="text" */
    input[type="text"] {
      border: 2px solid blue;
    }
    3.3 Partial Attribute Selectors
    • [attribute^="value"]: Selects elements where the attribute value starts with a specific value.
    /* Selects all <a> elements where href starts with "https" */
    a[href^="https"] {
      color: green;
    }
    • [attribute$="value"]: Selects elements where the attribute value ends with a specific value.
    /* Selects all <img> elements where src ends with ".jpg" */
    img[src$=".jpg"] {
      border: 2px solid red;
    }
    • [attribute*="value"]: Selects elements where the attribute value contains a specific substring.
    /* Selects all elements with a class name containing "btn" */
    [class*="btn"] {
      padding: 10px;
    }

    Pseudo-classes and Pseudo-elements

    4.1 Pseudo-classes

    Pseudo-classes target elements based on their state or position within the document.

    • :hover: Targets an element when the user hovers over it.
    /* Changes link color on hover */
    a:hover {
      color: red;
    }
    • :first-child: Selects the first child of its parent.
    /* Styles only the first paragraph within a container */
    .container p:first-child {
      font-weight: bold;
    }
    • :nth-child(n): Selects elements based on their position within a parent element.
    /* Styles every second list item */
    li:nth-child(2n) {
      background-color: #f0f0f0;
    }
    4.2 Pseudo-elements

    Pseudo-elements select a part of an element and apply styles to it.

    • ::before: Inserts content before the element’s actual content.
    /* Adds a bullet icon before list items */
    li::before {
      content: "• ";
      color: red;
    }
    • ::after: Inserts content after the element’s content.
    /* Adds a decorative line after headings */
    h2::after {
      content: "";
      display: block;
      width: 50%;
      height: 2px;
      background-color: black;
    }
    • ::first-letter: Styles the first letter of an element.
    /* Makes the first letter of paragraphs larger and bold */
    p::first-letter {
      font-size: 2em;
      font-weight: bold;
    }

    Specificity and Inheritance

    5.1 Specificity

    Specificity determines which styles are applied to an element when there are conflicting rules. It is calculated based on the types of selectors used:

    • Inline styles: Highest specificity (e.g., style="color: red;").
    • ID selectors: High specificity (#header).
    • Class, attribute, and pseudo-class selectors: Medium specificity (.highlight[type="text"]:hover).
    • Element selectors: Lowest specificity (h1p).


    Example of Conflicting Styles:

    /* Lower specificity */
    p {
      color: blue;
    }
    
    /* Higher specificity due to class selector */
    .highlight {
      color: green;
    }
    
    /* Highest specificity due to ID selector */
    #special {
      color: red;
    }

    If a paragraph has the class highlight and the ID special, it will be styled with the color red due to the ID selector’s higher specificity.

    5.2 Inheritance

    Some CSS properties, such as color and font-size, are inherited from a parent element to its children by default.

    /* Set the font color for the body */
    body {
      color: navy;
    }
    
    /* All child elements (e.g., <p>, <h1>) will inherit the color */

    Overriding Inherited Styles:

    You can override inherited styles using more specific selectors or applying inherit or initial values.

    /* Override inherited color */
    h1 {
      color: black;
    }

    Summary

    CSS selectors are powerful tools for targeting HTML elements and applying styles. Basic selectors (element, class, ID) are the foundation of styling, while grouping selectors help reduce redundancy. Attribute selectors provide flexibility in styling elements based on their attributes. Pseudo-classes and pseudo-elements allow for styling elements in specific states or targeting parts of elements. Understanding specificity is crucial for resolving conflicts between different styles, and knowledge of inheritance helps maintain consistent styling throughout your webpage. Mastering these selectors enables you to create dynamic, responsive, and well-organized stylesheets.

  • Introduction to CSS

    CSS (Cascading Style Sheets) is a fundamental technology used to style and visually organize HTML content on a web page. It separates content from design, allowing you to control layout, colors, fonts, and other aspects of the web page’s presentation. This makes websites more visually appealing, user-friendly, and responsive.

    What is CSS?

    CSS Introduction

    CSS stands for Cascading Style Sheets, and it is a stylesheet language used to describe the presentation of a document written in HTML (or XML). While HTML provides the structure of the webpage, CSS is responsible for the visual styling. It allows you to define how elements, such as text, images, and buttons, appear on the screen, in print, or on other media.

    Key Features of CSS:
    • Styling: Change colors, fonts, spacing, and more.
    • Layout: Control the positioning of elements using layouts like Flexbox and Grid.
    • Responsive Design: Create web pages that adjust seamlessly to different screen sizes and devices.
    • Separation of Content and Design: By using CSS, you keep your HTML clean and semantic, focusing only on structure.

    Importance of CSS in Web Development

    • Enhanced User Experience: CSS enables you to style content in a way that is aesthetically pleasing, improving readability and user interaction.
    • Consistency: By linking a single CSS file to multiple HTML pages, you maintain a consistent look and feel across the website.
    • Accessibility: Properly applied CSS can enhance accessibility for users with disabilities by controlling how content is presented.
    • Efficient Maintenance: With CSS, you can change the style of an entire website by modifying a single stylesheet, saving time and effort.
    • Performance Optimization: CSS can improve page load times, especially when using techniques like CSS compression and external stylesheets.

    Basic CSS Syntax

    CSS syntax consists of a selector and a declaration block. The selector targets the HTML element(s) you want to style, and the declaration block contains one or more declarations separated by semicolons.

    Example of CSS Syntax:
    /* Selector */
    h1 {
      /* Declaration block */
      color: blue;        /* Property and value */
      font-size: 24px;    /* Another property and value */
    }
    Explanation:
    • Selector (h1): Specifies the HTML element to be styled.
    • Declaration Block ({ ... }): Contains one or more declarations.
    • Declaration (color: blue;): Consists of a property (color) and a value (blue), ending with a semicolon.
    • Property: The aspect of the element you want to change (e.g., colorfont-size).
    • Value: Specifies the setting for the property (e.g., blue24px).
     
    CSS Comments:

    You can add comments in CSS using /* ... */. Comments are ignored by the browser and are useful for explaining code or organizing styles.

    /* This is a comment */
    p {
      color: red; /* Change text color to red */
    }

    Adding CSS to HTML

    There are three ways to apply CSS to an HTML document: InlineInternal, and External.

    4.1 Inline CSS

    Inline CSS is added directly to an HTML element using the style attribute. This method is useful for applying a unique style to a single element.

    <h1 style="color: blue; font-size: 24px;">This is an inline styled heading</h1>

    Pros: Quick and easy for single-use styles. Cons: Not reusable, can clutter HTML, and is difficult to maintain.

    4.2 Internal CSS (Embedded CSS)

    Internal CSS is defined within the <style> tag inside the <head> section of an HTML document. It applies styles to elements on that specific page.

    <!DOCTYPE html>
    <html>
    <head>
      <style>
        p {
          color: green;
          font-size: 18px;
        }
      </style>
    </head>
    <body>
      <p>This is a paragraph styled with internal CSS.</p>
    </body>
    </html>

    Pros: Useful for styling a single page. Cons: Not reusable across multiple pages and can make the HTML file larger.

    4.3 External CSS

    External CSS is the most efficient and commonly used method. It involves linking an external .css file to the HTML document using the <link> tag in the <head> section. The external file contains all the styles for the website, allowing for consistent styling across multiple pages.

    HTML File:

    <!DOCTYPE html>
    <html>
    <head>
      <link rel="stylesheet" href="styles.css">
    </head>
    <body>
      <h1>This is a heading styled with external CSS.</h1>
      <p>This is a paragraph.</p>
    </body>
    </html>

    External CSS File (styles.css):

    h1 {
      color: blue;
      font-size: 24px;
    }
    
    p {
      color: green;
      font-size: 18px;
    }

    Pros: Centralizes styles in one file, makes maintenance easier, and promotes reusability. Cons: Requires additional HTTP requests to load the CSS file (though modern techniques like caching can mitigate this).

    Summary

    CSS is an essential part of modern web development that allows you to control the presentation of web pages, separating style from structure. By using CSS, you can create visually appealing, responsive, and accessible websites. CSS syntax consists of selectors and declaration blocks that define styles for HTML elements. You can add CSS to HTML in three ways: inline (directly in elements), internal (within the <style> tag), and external (linking to a .css file). The external method is the most efficient and commonly used in professional web development for its ease of maintenance and reusability. Understanding how to use CSS effectively is key to creating attractive and user-friendly web pages.

  • CSS Tutorial Roadmap

    Introduction to CSS

    • What is CSS?
    • Importance of CSS in Web Development
    • Basic CSS Syntax
    • Adding CSS to HTML

    CSS Selectors

    • Basic Selectors
    • Grouping Selectors
    • Attribute Selectors
    • Pseudo-classes and Pseudo-elements
    • Specificity and Inheritance

    CSS Properties and Values

    • Text Properties
    • Font Properties
    • Color Properties
    • Background Properties
    • Border Properties
    • Margin and Padding
    • Box Model

    CSS Layout

    Flex-wrap
    • Display Property
    • Positioning (Static, Relative, Absolute, Fixed, Sticky)
    • Flexbox
    • CSS Grid
    • Float and Clear

    Responsive Web Design

    • Media Queries
    • Responsive Images
    • Mobile-first Design
    • Viewport Meta Tag

    CSS Units

    • Absolute Units (px, pt, cm, in)
    • Relative Units (em, rem, %, vw, vh)

    CSS Transitions and Animations

    • CSS Transitions
    • CSS Animations
    • Keyframes
    • Transformations

    Advanced CSS

    • CSS Variables
    • CSS Functions (calc, min, max, clamp)
    • CSS Preprocessors (Sass, Less)
    • CSS Frameworks (Bootstrap, Tailwind CSS)

    CSS Best Practices

    • Writing Maintainable CSS
    • BEM Methodology
    • CSS Organization
    • Performance Optimization