Here are Top 25 multiple-choice questions (MCQs) focused on the HTML5 features and elements in CSS (Cascading Style Sheets) MCQs, along with their answers and explanations.
1. What does CSS stand for?
- Computer Style Sheets
- Creative Style Sheets
- Cascading Style Sheets
- Colorful Style Sheets
CSS stands for Cascading Style Sheets, which are used to describe the presentation and styling of web documents.
2. Which HTML tag is used to include an external CSS file in an HTML document?
- `<style>`
- `<link>`
- `<script>`
- `<css>`
The `<link>` tag is used to include an external CSS file in an HTML document.
3. What is the primary purpose of CSS?
- To create dynamic web content
- To define the structure of a webpage
- To enhance the functionality of web pages
- To control the visual presentation of web pages
The primary purpose of CSS is to control the visual presentation of web pages, including layout, colors, fonts, and other styling aspects.
4. What is the selector in CSS used for?
- To specify which HTML elements are affected by the style rule
- To define a new CSS property
- To create a comment in the CSS code
- To include external CSS files
The selector in CSS is used to specify which HTML elements are affected by the style rule. It defines the target elements.
5. What does the term "Cascading" refer to in CSS?
- It means that styles can be applied in layers or levels
- It refers to the use of multiple style sheets in a single document
- It signifies the process of style inheritance and overwriting
- It denotes a specific CSS property
The term "Cascading" in CSS refers to the process of style inheritance and overwriting, where styles can cascade from multiple sources to determine the final style.
6. Which CSS property is used to change the background color of an element?
- `text-color`
- `foreground-color`
- `background-color`
- `color`
The `background-color` property is used to change the background color of an element in CSS.
7. In CSS, what is the purpose of the "property" in a style rule?
- To define the elements affected by the rule
- To specify the value of the style
- To select the style rule
- To create a comment in the CSS code
In a CSS style rule, the "property" is used to specify the value of the style that will be applied to the selected elements.
8. What is the default behavior of a browser if CSS is not applied to an HTML document?
- The browser displays a blank page
- The browser uses the default browser styles
- The browser prompts the user to define styles
- The browser refuses to load the page
If CSS is not applied to an HTML document, the browser will use its default browser styles to display the content.
9. Which CSS property is used to specify the font of an element's text?
- `font-family`
- `text-font`
- `font-type`
- `text-family`
The `font-family` property is used to specify the font of an element's text in CSS.
10. What is the purpose of the "value" in a CSS style rule?
- To define the elements affected by the rule
- To select the style rule
- To specify the style property
- To specify the style property's value
In a CSS style rule, the "value" is used to specify the value of the style property.
11. Which CSS selector targets all HTML elements of a specific type, such as all paragraphs (`<p>`) in a document?
- Universal Selector (*)
- Element Selector
- Class Selector
- ID Selector
The Element Selector targets all HTML elements of a specific type in a document.
12. What does the term "stylesheet" refer to in CSS?
- A web page's content
- The HTML structure of a document
- The CSS code applied to a document
- The external CSS file used to style a document
In CSS, a "stylesheet" refers to the external CSS file used to style a document.
13. What is the purpose of the "class" attribute in HTML and CSS?
- To create a comment in the HTML code
- To identify unique elements in a document
- To apply a specific style to multiple elements
- To define a new HTML element
The "class" attribute is used to apply a specific style to multiple elements in HTML and CSS.
14. What is the role of the "ID" selector in CSS?
- To select multiple elements with the same identifier
- To create a comment in the CSS code
- To select a single unique element in a document
- To define a new CSS property
The "ID" selector in CSS is used to select a single unique element in a document.
15. Which CSS property is used to control the spacing between lines of text within an element?
- line-height
- text-spacing
- line-spacing
- text-line
The line-height property is used to control the spacing between lines of text within an element in CSS.
16. What is the purpose of the "margin" property in CSS?
- To set the background color of an element
- To define the space around an element
- To change the font of text
- To control the text alignment
The "margin" property in CSS is used to define the space around an element, creating space between elements.
17. Which CSS property is used to specify the size of an element's text, relative to its parent element's font size?
- font-size
- text-size
- size
- font-relative
The font-size property is used to specify the size of an element's text, relative to its parent element's font size.
18. What is the role of the "pseudo-class" in CSS?
- To select elements based on their attribute values
- To create animations and transitions
- To apply styles to specific states of an element
- To define custom HTML elements
The "pseudo-class" in CSS is used to apply styles to specific states of an element, such as when it's hovered over or in focus.
19. What is the purpose of the "float" property in CSS?
- To control the spacing between lines of text
- To align text within an element
- To specify the position of an element relative to its parent
- To change the background color of an element
The "float" property in CSS is used to specify the position of an element relative to its parent, often for creating layouts.
20. What does the term "box model" refer to in CSS?
- The model used for creating 3D shapes in CSS
- The representation of boxes used in CSS layouts
- The model for creating animation effects in CSS
- The CSS syntax for defining styles
The "box model" in CSS refers to the representation of boxes used in CSS layouts, including content, padding, borders, and margins.
21. Which CSS property is used to apply a shadow effect to an element, providing depth and dimension?
- text-shadow
- box-shadow
- element-shadow
- shadow-effect
The box-shadow property is used to apply a shadow effect to an element, providing depth and dimension in CSS.
22. What is the purpose of the "media query" in CSS?
- To define a new media type
- To apply styles based on the device's screen size and features
- To create transitions and animations
- To change the font of text
The "media query" in CSS is used to apply styles based on the device's screen size and features, making web pages responsive.
23. What CSS property is used to control the alignment of text within an element?
- text-align
- text-center
- text-justify
- text-position
The text-align property is used to control the alignment of text within an element in CSS.
24. In CSS, what is the purpose of the "z-index" property?
- To change the font of text
- To control the visibility of an element
- To specify the position of an element in the z-axis
- To create transitions and animations
The "z-index" property in CSS is used to specify the position of an element in the z-axis, affecting the stacking order of elements.
25. What CSS property is used to define the appearance of the border around an element?
- border-color
- border-style
- border-width
- border
The border property in CSS is used to define the appearance of the border around an element, including its color, style, and width.