ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP3144Css3
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP3144

    Web Technologies

    Progress0 / 38 done
    Topics38
    1Introduction to Web Applications2TCP/IP Application Services
    3Basic Operation4Virtual Hosting5Chunked Transfers6Caching Support7Extensibility8SGML9HTML510CSS3
    11Core XML12XHTML13XHTML MP
    14SOAP15REST16WML17XSL
    18Operations19Processing HTTP Requests20Processing HTTP Responses21Cookie Coordination22Privacy and P3P23Complex HTTP Interactions24Dynamic Content Delivery25Server Configuration26Server Security27Web Browsers Architecture and Processes
    28JavaScript29DHTML30AJAX31JSON32Approaches to Web Application Development33Programming in Any Scripting Language34Search Technologies35Search Engine Optimization36XML Query Language37Semantic Web38Future Web Application Framework
    7 min read
    Topic 10 of 38
    Topic Study Note Illustration
    10

    CSS3

    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...

    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 view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    7mremaining
    1.2kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Web Technologies