CSS MCQs – Responsive Web Design and Media Queries

11.) What is the purpose of the max-height media query?

A) It applies styles if the viewport height is equal to or less than the specified value
B) It applies styles if the viewport height is equal to or greater than the specified value
C) It applies styles if the viewport width is equal to or less than the specified value
D) It applies styles if the viewport width is equal to or greater than the specified value

Answer: Option A

Explanation: The max-height media query applies styles if the viewport height is equal to or less than the specified value.

12.) What is the correct syntax for defining a media query in CSS?

A) @media { query: …; }
B) media query { … }
C) media-query { … }
D) @media query { … }

Answer: Option D

Explanation: The media query @media query { … } is the correct syntax.

13.) Which media query targets devices with a specific aspect ratio, such as widescreen monitors?

A) @media (aspect-ratio: 16/9)
B) @media (orientation: landscape)
C) @media (min-aspect-ratio: 16/9)
D) @media (max-aspect-ratio: 16/9)

Answer: Option A

Explanation: The aspect-ratio media query with specific values targets devices with a specific aspect ratio, such as 16:9 widescreen monitors.

14.) What is the purpose of the pointer media feature?

A) It targets devices with specific pointing devices, such as a mouse or touchscreen
B) It targets devices with specific screen resolutions
C) It targets devices with specific aspect ratios
D) It targets devices with specific screen widths

Answer: Option A

Explanation: The pointer media feature targets devices with specific pointing devices, such as a mouse or touchscreen.

15.) Which CSS property is commonly used to adjust the layout based on the screen orientation?

A) orientation
B) display
C) flex-direction
D) text-align

Answer: Option C

Explanation: The flex-direction property is commonly used in Flexbox layouts to adjust the layout based on the screen orientation.

16.) What is the purpose of the color media feature?

A) It targets devices with specific screen widths
B) It targets devices with specific screen resolutions
C) It targets devices with specific aspect ratios
D) It targets devices with specific color capabilities

Answer: Option D

Explanation: The color media feature targets devices with specific color capabilities, such as monochrome or color displays.

17.) What does the following media query target: @media (max-height: 600px)?

A) Viewports with a height less than or equal to 600 pixels
B) Viewports with a height greater than or equal to 600 pixels
C) Viewports with a width less than or equal to 600 pixels
D) Viewports with a width greater than or equal to 600 pixels

Answer: Option A

Explanation: The max-height media query targets viewports with a height less than or equal to 600 pixels.

18.) Which media query targets devices with a specific screen width?

A) @media (max-width: 768px)
B) @media (min-width: 768px)
C) @media (max-height: 768px)
D) @media (min-height: 768px)

Answer: Option B

Explanation: @media (min-width: 768px) is the correct answer. This media query targets devices with a minimum screen width of 768 pixels, which aligns with the requirement of targeting devices with a specific screen width.

19.) Which media query syntax targets devices with a screen width between 600px and 900px?

A) @media (min-width: 600px) and (max-width: 900px) { … }
B) @media (min-width: 600px, max-width: 900px) { … }
C) @media (width >= 600px && width <= 900px) { … }
D) @media (600px <= width <= 900px) { … }

Answer: Option A

Explanation: @media (min-width: 600px) and (max-width: 900px) { … } is the correct syntax for targeting devices with a screen width between 600px and 900px.

20.) Which of the following media query syntaxes is incorrect?

A) @media (min-width: 768px) and (max-width: 1024px) { … }
B) @media (min-height: 600px), (max-height: 800px) { … }
C) @media (min-device-width: 320px) and (max-device-width: 480px) { … }
D) @media (orientation: portrait), (orientation: landscape) { … }

Answer: Option D

Explanation: The incorrect syntax in option D is using multiple values for the same media feature within the same media query. Media queries can’t be written with multiple values for the same media feature like this.

Leave a Reply

Your email address will not be published. Required fields are marked *