1. Home
  2. Explore
  3. Computer Science
  4. Website with HTML & CSS

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Website with HTML & CSS

  • 25Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: CSS Reset

What is the purpose of setting margin: 0; padding: 0; in CSS before styling other elements?

25 questions

  1. 1

    What is the purpose of setting margin: 0; padding: 0; in CSS before styling other elements?

    Model answer

    To remove default browser margins and padding, ensuring a consistent baseline for custom styling.

    Explanation

    Browsers apply default margins and paddings on elements like body; resetting them prevents unexpected spacing.

  2. 2

    How do you link an external CSS file named style.css to an HTML document?

    Model answer

    Use <link rel="stylesheet" href="style.css"> inside the <head> section.

    Explanation

    The <link> tag with rel="stylesheet" and href pointing to the CSS file is the standard method.

  3. 3

    What CSS property and value are used to create a linear gradient background?

    Model answer

    background: linear-gradient(direction, color-stop1, color-stop2, ...);

    Explanation

    The linear-gradient() function allows smooth color transitions; direction can be to top, to bottom, to left, to right, or an angle.

  4. 4

    How do you make a background image 50% dimmer using a linear gradient?

    Model answer

    Use background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('image.jpg');

    Explanation

    A semi-transparent black overlay (rgba(0,0,0,0.5)) layered on top of the background image reduces brightness.

  5. 5

    What CSS properties are needed to set a background image to cover the entire element and center it?

    Model answer

    background-size: cover; background-position: center;

    Explanation

    cover scales the image to cover the element while maintaining aspect ratio; center positions it centrally.

  6. 6

    What does height: 100vh; achieve in CSS?

    Model answer

    It sets the element's height to 100% of the viewport height.

    Explanation

    vh stands for viewport height; 100vh equals the full visible height of the browser window.

  7. 7

    How do you center a block element horizontally using margin?

    Model answer

    Set margin: auto; on the element with a defined width.

    Explanation

    When an element has a width less than its container, margin: auto distributes equal space left and right.

  8. 8

    What does display: flex; do to a container?

    Model answer

    It enables a flexbox layout, allowing flexible alignment and distribution of child elements.

    Explanation

    Flexbox provides powerful alignment properties like justify-content and align-items.

  9. 9

    How do you center items both horizontally and vertically using flexbox?

    Model answer

    Use display: flex; justify-content: center; align-items: center;

    Explanation

    justify-content: center centers along the main axis; align-items: center centers along the cross axis.

  10. 10

    What CSS property removes the default bullet points from an unordered list?

    Model answer

    list-style: none;

    Explanation

    Setting list-style to none removes markers (bullets, numbers) from list items.

  11. 11

    How do you change the color of an anchor link and remove its underline?

    Model answer

    Use color: desired-color; text-decoration: none;

    Explanation

    text-decoration: none removes the underline; color sets the text color.

  12. 12

    What CSS property and value create a smooth color change when hovering over an element?

    Model answer

    transition: property duration timing-function; e.g., transition: 0.4s ease-in-out;

    Explanation

    The transition property animates changes over a specified duration with an easing function.

  13. 13

    Write CSS to change an element's background color to orange on hover.

    Model answer

    element:hover { background: orange; }

    Explanation

    The :hover pseudo-class applies styles when the mouse pointer is over the element.

  14. 14

    How do you create a search input with a rounded left border and a button with a rounded right border?

    Model answer

    Set border-top-left-radius and border-bottom-left-radius on the input, and border-top-right-radius and border-bottom-right-radius on the button.

    Explanation

    Border-radius properties control individual corners; combining them creates a seamless joined search bar.

  15. 15

    What does background: transparent; do on an input field?

    Model answer

    It makes the input's background transparent, allowing the parent's background to show through.

    Explanation

    transparent sets the background to fully see-through; often used with a colored border for a modern look.

  16. 16

    How do you remove the default focus outline from an input field?

    Model answer

    Use input:focus { outline: none; }

    Explanation

    Removing the outline can affect accessibility; alternative focus indicators should be provided.

  17. 17

    What CSS property controls the space between letters?

    Model answer

    letter-spacing

    Explanation

    letter-spacing increases or decreases the space between characters in text.

  18. 18

    How do you position an element absolutely relative to its nearest positioned ancestor?

    Model answer

    Set position: absolute; on the element and position: relative; on the ancestor.

    Explanation

    Absolute positioning removes the element from normal flow and places it relative to the closest positioned (non-static) ancestor.

  19. 19

    What does cursor: pointer; do?

    Model answer

    It changes the mouse cursor to a hand icon, indicating the element is clickable.

    Explanation

    Commonly used on buttons and links to improve user experience.

  20. 20

    How do you change the color of placeholder text in an input field?

    Model answer

    Use ::placeholder pseudo-element with color property, e.g., input::placeholder { color: white; }

    Explanation

    The ::placeholder selector targets placeholder text specifically.

  21. 21

    What HTML elements are used to create a navigation menu with a list of links?

    Model answer

    <nav> or <div>, <ul>, <li>, and <a> tags.

    Explanation

    A typical navigation menu uses an unordered list (<ul>) with list items (<li>) containing anchor links (<a>).

  22. 22

    How do you create a login form with email and password fields?

    Model answer

    Use <form> containing <input type="email"> and <input type="password">, plus a submit button.

    Explanation

    The type="email" validates email format; type="password" masks input for security.

  23. 23

    What attribute is used in an anchor tag to link to an external page?

    Model answer

    The href attribute.

    Explanation

    href specifies the URL of the page the link goes to.

  24. 24

    How do you add social media icons from an icon library like Font Awesome?

    Model answer

    Use <i class="fab fa-facebook-f"></i> inside an anchor tag, with the appropriate class names.

    Explanation

    Font Awesome icons are applied via classes; fab for brand icons, fa- followed by the icon name.

  25. 25

    What is the purpose of the <span> tag in HTML?

    Model answer

    To group inline elements for styling without adding new lines.

    Explanation

    <span> is an inline container used to apply CSS or JavaScript to a portion of text.

1 of 25
Question 1 of 25

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent