Basic CSS Questions Part 2

ยท

3 min read

  1. What does the line-height property control in CSS?

    • It sets the height of a line box.
  2. How do you add a border to an element in CSS?

    • Using the border property.
  3. Explain the difference between padding and margin.

    • Padding is the space inside an element, while margin is the space outside the element.
  4. What is the purpose of the opacity property in CSS?

    • It specifies the transparency level of an element.
  5. How do you style links that have been visited in CSS?

    • Using the :visited pseudo-class.
  6. What is the purpose of the transition property in CSS?

    • It adds smooth transitions between property changes.
  7. How do you align text to the center in CSS?

    • Using text-align: center;.
  8. What is the purpose of the flexbox layout in CSS?

    • It provides an efficient way to lay out, align, and distribute space among items in a container.
  9. How do you change the font size in CSS?

    • Using the font-size property.
  10. What does the display: none; property do in CSS?

    • It hides the element completely from the layout.
  11. How do you apply a background image to an element in CSS?

    • Using the background-image property.
  12. What is the purpose of the cursor property in CSS?

    • It specifies the type of cursor to be displayed when hovering over an element.
  13. Explain the use of :hover in CSS.

    • It applies styles to an element when the user hovers over it.
  14. What is the purpose of @import in CSS?

    • It is used to import external style sheets into another style sheet.
  15. How do you add a shadow to an element in CSS?

    • Using the box-shadow property.
  16. What does the flex-direction property control in CSS Flexbox?

    • It determines the direction of the flex items within the flex container.
  17. How do you set the height and width of an element in CSS?

    • Using the height and width properties.
  18. What is the purpose of the word-wrap property in CSS?

    • It allows long words to be able to be broken and wrap onto the next line.
  19. How do you select all elements with a specific class in CSS?

    • Using .className { ... }.
  20. What is the purpose of the text-transform property in CSS?

    • It controls the capitalization of text.
  21. How do you make text bold in CSS?

    • Using the font-weight: bold; property.
  22. Explain the use of the background-size property in CSS.

    • It sets the size of the background image.
  23. What is the purpose of the flex-grow property in CSS Flexbox?

    • It specifies how much an item should grow relative to the rest of the flexible items inside the same container.
  24. How do you align items vertically in CSS Flexbox?

    • Using align-items property set to center, flex-start, or flex-end.
  25. What is the purpose of the outline property in CSS?

    • It adds a line around an element's border, outside the border edge.

Did you find this article valuable?

Support Namya Shah by becoming a sponsor. Any amount is appreciated!

ย