Basic CSS Questions Part 2
What does the
line-height
property control in CSS?- It sets the height of a line box.
How do you add a border to an element in CSS?
- Using the
border
property.
- Using the
Explain the difference between
padding
andmargin
.Padding
is the space inside an element, whilemargin
is the space outside the element.
What is the purpose of the
opacity
property in CSS?- It specifies the transparency level of an element.
How do you style links that have been visited in CSS?
- Using the
:visited
pseudo-class.
- Using the
What is the purpose of the
transition
property in CSS?- It adds smooth transitions between property changes.
How do you align text to the center in CSS?
- Using
text-align: center;
.
- Using
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.
How do you change the font size in CSS?
- Using the
font-size
property.
- Using the
What does the
display: none;
property do in CSS?- It hides the element completely from the layout.
How do you apply a background image to an element in CSS?
- Using the
background-image
property.
- Using the
What is the purpose of the
cursor
property in CSS?- It specifies the type of cursor to be displayed when hovering over an element.
Explain the use of
:hover
in CSS.- It applies styles to an element when the user hovers over it.
What is the purpose of
@import
in CSS?- It is used to import external style sheets into another style sheet.
How do you add a shadow to an element in CSS?
- Using the
box-shadow
property.
- Using the
What does the
flex-direction
property control in CSS Flexbox?- It determines the direction of the flex items within the flex container.
How do you set the height and width of an element in CSS?
- Using the
height
andwidth
properties.
- Using the
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.
How do you select all elements with a specific class in CSS?
- Using
.className { ... }
.
- Using
What is the purpose of the
text-transform
property in CSS?- It controls the capitalization of text.
How do you make text bold in CSS?
- Using the
font-weight: bold;
property.
- Using the
Explain the use of the
background-size
property in CSS.- It sets the size of the background image.
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.
How do you align items vertically in CSS Flexbox?
- Using
align-items
property set tocenter
,flex-start
, orflex-end
.
- Using
What is the purpose of the
outline
property in CSS?- It adds a line around an element's border, outside the border edge.
Subscribe to my newsletter
Read articles from Namya Shah directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Namya Shah
Namya Shah
I am a developer who is very enthusiast about technology and coding.