Pie Logo
Quiz: CSS Styles
by Tomas Trescak

QuizTest your understanding of the section content.

ContentDetailed description of the section content.

Full Stack Development
Introduction
Generative AI
🍰 Player
💼 Editor
Setup
React Fundamentals
JSX and Components
Props
Assignment 1.2: Front End
CSS Styles
Quiz: CSS Styles
useState and Hooks
Conditional Rendering
Lists
Forms and Events
Storybook
Assignment 1.3: Bonus - Backend
Leaderboards
Next.js
Advanced React
Databases
React Hooks
Authentication and Authorisation
APIs
CI/CD and DevOps
Testing React
Advanced Topics
    Pie Logo
    Quiz: CSS Styles
    by Tomas Trescak

    QuizTest your understanding of the section content.

    ContentDetailed description of the section content.

    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    JSX and Components
    Props
    Assignment 1.2: Front End
    CSS Styles
    Quiz: CSS Styles
    useState and Hooks
    Conditional Rendering
    Lists
    Forms and Events
    Storybook
    Assignment 1.3: Bonus - Backend
    Leaderboards
    Next.js
    Advanced React
    Databases
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics

    Quiz: CSS Styles
    by Tomas Trescak· CSS Styles

    QUESTION 1

    You’re building a React app for a client who wants a button that changes color when hovered over. You decide to use Tailwind CSS for rapid styling. Here’s the button code:

    <button className="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-700">Submit</button>
    

    What does the hover:bg-blue-700 class do, and why might Tailwind be a better choice here than inline styles?


    QUESTION 2

    Imagine you’re working on a team project where two developers accidentally use a .header class in separate CSS files:

    /* styles1.css */
    .header {
      color: red;
    }
    /* styles2.css */
    .header {
      color: blue;
    }
    

    You import both files into your React app with <link> tags in index.html. Your component looks like this:

    function Title() {
      return <h1 className="header">Welcome</h1>;
    }
    

    What problem arises, and how could CSS Modules fix it?


    QUESTION 3

    You’re tasked with styling a reusable card component in React. Here’s an attempt using inline styles:

    const cardStyle = { backgroundColor: '#f0f0f0', padding: '16px', borderRadius: '8px' };
    function Card({ title }) {
      return <div style={cardStyle}><h2>{title}</h2></div>;
    }
    

    A teammate suggests switching to Tailwind CSS with this:

    function Card({ title }) {
      return <div className="bg-gray-100 p-4 rounded-lg"><h2>{title}</h2></div>;
    }
    

    What’s a key limitation of inline styles here, and why might Tailwind be more practical?


    QUESTION 4

    You’re debugging a React app where a developer used a CSS file:

    /* styles.css */
    .code {
      font-family: monospace;
      color: #333;
    }
    

    Imported in app.tsx like this:

    import "./styles.css";
    function CodeBlock() {
      return <p className="code">console.log("Hello")</p>;
    }
    

    Meanwhile, a third-party library also defines a .code class with color: green. What happens, and how could CSS Modules prevent this?


    QUESTION 5

    You’re designing a responsive landing page in React with Tailwind CSS. Here’s a section:

    <div className="w-full sm:w-3/4 md:w-1/2 lg:w-1/3 bg-blue-200 p-6">
      <h1 className="text-xl md:text-2xl font-bold">Welcome</h1>
    </div>
    

    A client asks why the design adjusts across screen sizes. What’s happening in the code, and why is this useful?

    This content is only available to registered users.
    Please register at the the home page.

    Quiz: CSS Styles
    by Tomas Trescak· CSS Styles

    QUESTION 1

    You’re building a React app for a client who wants a button that changes color when hovered over. You decide to use Tailwind CSS for rapid styling. Here’s the button code:

    <button className="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-700">Submit</button>
    

    What does the hover:bg-blue-700 class do, and why might Tailwind be a better choice here than inline styles?


    QUESTION 2

    Imagine you’re working on a team project where two developers accidentally use a .header class in separate CSS files:

    /* styles1.css */
    .header {
      color: red;
    }
    /* styles2.css */
    .header {
      color: blue;
    }
    

    You import both files into your React app with <link> tags in index.html. Your component looks like this:

    function Title() {
      return <h1 className="header">Welcome</h1>;
    }
    

    What problem arises, and how could CSS Modules fix it?


    QUESTION 3

    You’re tasked with styling a reusable card component in React. Here’s an attempt using inline styles:

    const cardStyle = { backgroundColor: '#f0f0f0', padding: '16px', borderRadius: '8px' };
    function Card({ title }) {
      return <div style={cardStyle}><h2>{title}</h2></div>;
    }
    

    A teammate suggests switching to Tailwind CSS with this:

    function Card({ title }) {
      return <div className="bg-gray-100 p-4 rounded-lg"><h2>{title}</h2></div>;
    }
    

    What’s a key limitation of inline styles here, and why might Tailwind be more practical?


    QUESTION 4

    You’re debugging a React app where a developer used a CSS file:

    /* styles.css */
    .code {
      font-family: monospace;
      color: #333;
    }
    

    Imported in app.tsx like this:

    import "./styles.css";
    function CodeBlock() {
      return <p className="code">console.log("Hello")</p>;
    }
    

    Meanwhile, a third-party library also defines a .code class with color: green. What happens, and how could CSS Modules prevent this?


    QUESTION 5

    You’re designing a responsive landing page in React with Tailwind CSS. Here’s a section:

    <div className="w-full sm:w-3/4 md:w-1/2 lg:w-1/3 bg-blue-200 p-6">
      <h1 className="text-xl md:text-2xl font-bold">Welcome</h1>
    </div>
    

    A client asks why the design adjusts across screen sizes. What’s happening in the code, and why is this useful?

    This content is only available to registered users.
    Please register at the the home page.

    Pie Logo
    Quiz: CSS Styles
    by Tomas Trescak
    Pie Logo
    Quiz: CSS Styles
    by Tomas Trescak
    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    JSX and Components
    Props
    Assignment 1.2: Front End
    CSS Styles
    Quiz: CSS Styles
    useState and Hooks
    Conditional Rendering
    Lists
    Forms and Events
    Storybook
    Assignment 1.3: Bonus - Backend
    Leaderboards
    Next.js
    Advanced React
    Databases
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics
    Full Stack Development
    Introduction
    Generative AI
    🍰 Player
    💼 Editor
    Setup
    React Fundamentals
    JSX and Components
    Props
    Assignment 1.2: Front End
    CSS Styles
    Quiz: CSS Styles
    useState and Hooks
    Conditional Rendering
    Lists
    Forms and Events
    Storybook
    Assignment 1.3: Bonus - Backend
    Leaderboards
    Next.js
    Advanced React
    Databases
    React Hooks
    Authentication and Authorisation
    APIs
    CI/CD and DevOps
    Testing React
    Advanced Topics