Basics CSS Questions Part 1
I am a developer who is very enthusiast about technology and coding.
What does CSS stand for?
- Cascading Style Sheets.
What is the purpose of CSS?
- It's used to style the layout and appearance of web pages.
How do you link an external CSS file to an HTML document?
- Using the
<link>tag within the HTML<head>section, like this:<link rel="stylesheet" href="styles.css">.
- Using the
What is the difference between padding and margin in CSS?
- Padding is the space inside an element, while margin is the space outside the element.
How do you select an element by its ID in CSS?
- Using
#followed by the ID name. For instance,#myElement { ... }.
- Using
Explain the box model in CSS.
- The box model describes how elements are rendered on a web page, including content, padding, border, and margin.
What is the default display property for most elements in CSS?
display: block;for elements like<div>,<p>, etc., anddisplay: inline;for elements like<span>.
How do you center an element horizontally in CSS?
- Using
margin: 0 auto;with a fixed width ortext-align: center;for inline elements within a container.
- Using
What are pseudo-classes in CSS?
- They are keywords added to selectors that specify a special state of the selected elements.
What is the difference between
inlineandblockelements in CSS?Inlineelements do not start on a new line and only take up as much width as necessary, whileblockelements start on a new line and take up the full width available.
Explain the difference between
paddingandmargin.Paddingis the space inside an element, whilemarginis the space outside the element.
What is the purpose of
z-indexin CSS?- It determines the stacking order of positioned elements.
How do you include comments in CSS?
- Using
/* */around the comment text.
- Using
What is the difference between
emandremunits in CSS?emunits are relative to the font size of the nearest parent element, whileremunits are relative to the root element's font size.
How do you make a text italic in CSS?
- Using the
font-style: italic;property.
- Using the
What is the use of the
floatproperty in CSS?- It's used to position elements to the left or right inside their container.
How do you apply a background color to an element in CSS?
- Using the
background-colorproperty.
- Using the
What is the purpose of the
positionproperty in CSS?- It defines the type of positioning method used for an element.
Explain the difference between
classandidin CSS.Classcan be used multiple times in a document, whileidmust be unique within a document.
How do you hide an element in CSS?
- Using
display: none;.
- Using
What does the
overflowproperty do in CSS?- It specifies what should happen if content overflows its containing element.
What is the purpose of the
box-sizingproperty in CSS?- It defines how the total width and height of an element are calculated.
How do you set the text color in CSS?
- Using the
colorproperty.
- Using the
What is the purpose of the
@mediarule in CSS?- It is used to apply different styles for different media types/devices.
How do you select all paragraphs in CSS?
- Using the
pselector:p { ... }.
- Using the

