CSS Questions and Answers
CSS Questions and Answers
- External CSS: Using the <link> tag in the HTML file to link to an external stylesheet.
- Internal CSS: Using the <style> tag within the <head> of the HTML document.
- Inline CSS: Adding the style attribute directly within an HTML element.
2. Important keyword
Answer: The !important keyword in CSS gives a style declaration higher priority, overriding other
3. Selector
Answer: A CSS selector is a pattern used to select elements for styling. For example, .class, #id,
Answer: Pseudo-class: Used to define the special state of an element, e.g., :hover, :nth-child().
Answer: The min-width property is used when you want to ensure that an element cannot be resized
smaller than a specified minimum width.
8. Font property
Answer: The font property in CSS is shorthand for setting font-style, font-variant, font-weight,
Answer: - block
- inline
- inline-block
- none
- flex
- grid
Answer: - visible: Content is not clipped and may overflow the element.
- hidden: Overflow is clipped, and the rest of the content is not visible.
- External CSS.
- Internal CSS.
- Inline CSS (within elements).
Answer: Internal CSS is written within a <style> tag inside the <head> section of the HTML file.
Answer: - Block elements: Take up the full width and start on a new line (e.g., <div>, <p>).
- Inline elements: Take only the necessary width and do not start on a new line (e.g., <span>, <a>).
- Background shorthand: background: color image position/size repeat origin clip attachment.
Answer: The default value of the position property is static, meaning the element is positioned
Answer: The position property specifies the type of positioning method used for an element. Values