ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Web Technologies
    EC-331
    Progress0 / 38 topics
    Topics
    1. Introduction to Web Applications2. TCP/IP Application Services3. Web Servers: Basic Operation4. Web Servers: Virtual Hosting5. Web Servers: Chunked Transfers6. Web Servers: Caching Support7. Web Servers: Extensibility8. SGML9. HTML510. CSS311. XML Languages and Applications: Core XML12. XML Languages and Applications: XHTML13. XML Languages and Applications: XHTML MP14. Web Service: SOAP15. Web Service: REST16. Web Service: WML17. Web Service: XSL18. Web Services: Operations19. Web Services: Processing HTTP Requests20. Web Services: Processing HTTP Responses21. Web Services: Cookie Coordination22. Web Services: Privacy and P3P23. Web Services: Complex HTTP Interactions24. Web Services: Dynamic Content Delivery25. Server Configuration26. Server Security27. Web Browsers Architecture and Processes28. Active Browser Pages: JavaScript29. Active Browser Pages: DHTML30. Active Browser Pages: AJAX31. JSON32. Approaches to Web Application Development33. Programming in Any Scripting Language34. Search Technologies35. Search Engine Optimization36. XML Query Language37. Semantic Web38. Future Web Application Framework
    EC-331›CSS3
    Web TechnologiesTopic 10 of 38

    CSS3

    7 minread
    1,157words
    Intermediatelevel

    CSS3 (Cascading Style Sheets, Version 3)

    CSS3 is the latest version of CSS (Cascading Style Sheets), which is the style sheet language used to describe the presentation and layout of a web page written in HTML or XML. CSS allows web developers to separate content (HTML) from the visual design and layout, which makes websites more maintainable and accessible.

    CSS3 is an update to the original CSS specification and introduces a variety of new features and capabilities, including better control over layout, animations, transitions, and responsive design.

    Key Features and Improvements in CSS3

    1. Selectors:

    CSS3 introduces several new selectors, allowing developers to target HTML elements more precisely.

    • Attribute Selectors: Select elements based on their attributes.
      a[href^="https"] {
          color: green; /* Selects links starting with 'https' */
      }
      
    • Pseudo-Classes: CSS3 adds several new pseudo-classes to target elements based on their state or position.
      • :nth-child(): Selects elements based on their position in a parent.
        li:nth-child(2) {
            color: red; /* Selects the second list item */
        }
        
      • :not(): Selects elements that do not match a given selector.
        p:not(.special) {
            font-size: 16px;
        }
        
    • Pseudo-Elements: CSS3 enhances the ability to style parts of elements using pseudo-elements like ::before and ::after.
      p::after {
          content: " (End of Paragraph)";
      }
      

    2. Box Model and Layout:

    CSS3 provides enhanced control over layout and presentation through new properties and enhancements to the box model.

    • box-sizing: This property allows developers to control how width and height are calculated in relation to padding and borders.

      div {
          box-sizing: border-box;
      }
      

      This ensures that padding and border are included in the element's total width and height.

    • Flexbox: The Flexible Box Layout (Flexbox) is a powerful layout model for creating flexible and responsive layouts. It provides tools to distribute space dynamically and align elements.

      .container {
          display: flex;
          justify-content: space-between;
      }
      

      Flexbox can handle complex layouts with ease, including vertical centering and distributing space between elements.

    • Grid Layout: The CSS Grid Layout system provides a 2D grid-based layout system that allows for more complex designs and precise control over rows and columns.

      .container {
          display: grid;
          grid-template-columns: 1fr 2fr;
          grid-gap: 10px;
      }
      

    3. Backgrounds and Borders:

    CSS3 offers advanced options for controlling the background and borders of elements.

    • Multiple Backgrounds: You can now apply multiple background images to an element.

      div {
          background: url('image1.jpg'), url('image2.jpg');
          background-position: top left, bottom right;
      }
      
    • Border Radius: CSS3 introduces the border-radius property, which allows for rounded corners on elements.

      div {
          border-radius: 15px;
      }
      
    • Box Shadows: You can apply shadows to elements to create depth or highlight them.

      div {
          box-shadow: 10px 10px 20px rgba(0,0,0,0.5);
      }
      
    • Text Shadows: Similarly, you can apply shadows to text.

      h1 {
          text-shadow: 2px 2px 5px gray;
      }
      

    4. Transitions and Animations:

    CSS3 provides tools to animate changes in style and create more dynamic, interactive web pages.

    • Transitions: The transition property allows for smooth transitions when property values change.

      div {
          transition: all 0.3s ease;
      }
      div:hover {
          background-color: blue;
      }
      

      When the user hovers over the div, the background color will change smoothly over 0.3 seconds.

    • Animations: The @keyframes rule lets you create complex animations with multiple steps.

      @keyframes slide {
          from {
              left: 0;
          }
          to {
              left: 100px;
          }
      }
      
      div {
          position: relative;
          animation: slide 2s infinite alternate;
      }
      

    5. Typography:

    CSS3 improves how text is styled and displayed on web pages.

    • Web Fonts: Using the @font-face rule, you can load custom fonts on a web page, making it easier to use unique typefaces.

      @font-face {
          font-family: 'MyFont';
          src: url('myfont.woff2') format('woff2');
      }
      body {
          font-family: 'MyFont', sans-serif;
      }
      
    • Text Overflow: CSS3 introduces the text-overflow property, which can be used to handle text that overflows its container.

      .container {
          width: 200px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
      }
      

    6. Responsive Design:

    Responsive web design is the approach to designing websites that work well across a variety of devices, including desktops, tablets, and smartphones. CSS3 introduces several features that make responsive design easier.

    • Media Queries: These allow you to apply styles based on the device's characteristics, such as width, height, or orientation.

      @media (max-width: 600px) {
          body {
              font-size: 14px;
          }
      }
      
    • Viewport Units: CSS3 introduces vw (viewport width), vh (viewport height), vmin, and vmax, which allow you to size elements relative to the viewport size.

      .container {
          width: 100vw; /* 100% of the viewport width */
          height: 100vh; /* 100% of the viewport height */
      }
      

    7. Transforms:

    CSS3 allows you to apply transformations to elements, enabling rotation, scaling, skewing, and translation.

    • Transform Property: This property enables you to change the position, size, and shape of elements.

      div {
          transform: rotate(45deg);
      }
      
    • 3D Transforms: CSS3 also supports 3D transformations, enabling elements to be rotated in 3D space.

      div {
          transform: rotateX(45deg) rotateY(45deg);
      }
      

    8. CSS Variables (Custom Properties):

    CSS3 introduced CSS variables, which allow developers to define reusable values in their stylesheets.

    :root {
        --main-color: #3498db;
    }
    div {
        background-color: var(--main-color);
    }
    

    Advantages of CSS3

    1. Better Control Over Layout: CSS3 introduces powerful layout modules like Flexbox and Grid, which allow for easier and more flexible layout management, especially when dealing with complex designs.

    2. Rich Visual Effects: With features like animations, transitions, shadows, and gradients, CSS3 provides a wide range of visual effects that were previously only achievable through JavaScript or images.

    3. Mobile-First Design: CSS3’s support for media queries and viewport units makes it easier to design responsive websites that work across various screen sizes, promoting the mobile-first approach.

    4. Performance and Accessibility: By using CSS3 for animations and transformations, developers can offload tasks to the GPU, improving performance. Additionally, CSS3 improves accessibility with better control over styling and positioning of elements.

    5. Cleaner and More Efficient Code: CSS3 reduces the need for JavaScript-heavy approaches or large image files for styling and effects. This leads to cleaner and more maintainable code.

    Conclusion

    CSS3 has significantly enhanced the capabilities of web design, providing developers with powerful tools for layout control, animations, and responsive design. It enables the creation of visually appealing and interactive websites with smoother user experiences, all while keeping code more maintainable and efficient. As web design continues to evolve, CSS3 remains an essential technology for creating modern, dynamic, and mobile-friendly websites.

    Previous topic 9
    HTML5
    Next topic 11
    XML Languages and Applications: Core XML

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time7 min
      Word count1,157
      Code examples0
      DifficultyIntermediate