HTML/CSS MCQ

HTML/CSS MCQs – Multiple Choice Questions and Answers – Part 23

Multiple choice questions and answers (MCQs) on HTML/CSS to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as tags, web standards, CSS selector, objects, and more. This quiz will easily prepare anyone to pass their online test.
 
 

1. Which CSS property defines a grid layout?

A display: grid;

B display: inline-block;

C display: flex;

D grid-layout: true;

A
The display: grid; property defines a CSS grid container, allowing child elements to be positioned in rows and columns based on a grid layout.
 

2. Which CSS function is used to create a radial gradient?

A linear-gradient()

B radial-gradient()

C gradient-radial()

D circle-gradient()

B
The radial-gradient() function creates a radial color transition starting from the center and expanding outward. See a full example.
 

3. Which HTML tag is used to include a quote in a web page?

A <quote>

B <q>

C <cite>

D <blockquote>

B
The <q> tag is used for short inline quotes. For longer quotes, use <blockquote>. Example:

Albert Einstein said:

Life is like riding a bicycle. To keep your balance, you must keep moving.

 
 

4. Which HTML tag allows you to add a responsive image that adapts to the size of its container?

A <img src="image.jpg">

B <img src="image.jpg" width="100%">

C <picture><source srcset="image.jpg"><img src="image.jpg"></picture>

D <img src="image.jpg" style="width: 100%;">

C
The <picture> tag with <source srcset="image.jpg"> allows you to create responsive images based on screen size.
 

5. What is the effect of the following CSS rule on a Flexbox container?
.container {
   display: flex;
   justify-content: center;
   align-items: center;
}

A Items align to the top-left corner

B Items are centered both horizontally and vertically

C Items are stacked on top of each other

D Items align to the right only

B
justify-content: center centers items horizontally, and align-items: center centers them vertically.
 

6. In a Flexbox container, what does the flex-wrap: wrap property do?

A Forces all items onto a single line

B Forces items into one line regardless of size

C Allows items to wrap onto multiple lines if needed

D Centers items on the line

C
The flex-wrap: wrap property allows items to wrap onto the next line if there isn’t enough space. See a full example.
 
 

7. What is the difference between a relative and an absolute link in HTML?

A A relative link uses a full URL, while an absolute link uses a relative path

B A relative link is based on the current page’s location, while an absolute link uses a full URL

C A relative link is always shorter than an absolute link

D There is no difference between the two types of links

B
A relative link is defined in relation to the current page’s location, while an absolute link includes the full URL, including the protocol (https://) and domain name.
 

8. Which CSS property is used to rotate an element?

A transform: rotate()

B rotate: transform()

C transform: rotateX()

D transform: angle()

A
The transform: rotate() property rotates an element by a specified angle in degrees (e.g., transform: rotate(45deg);). See a full example.
 

9. What behavior does the flex-grow property apply in a Flexbox container?

A It controls spacing between items

B It defines the width of each item

C It allows items to grow and fill the available space

D It adjusts item size based on content

C
The flex-grow property determines how items in a Flexbox container expand to fill extra space.
 
 

10. What is the effect of the following CSS rule on an element?
.element {
  position: fixed;
  top: 0;
  left: 0;
}

A The element is absolutely positioned relative to its parent

B The element is placed at the top-left of the page and remains visible during scrolling

C The element is centered on the page

D The element is placed at the bottom-right of the page

B
The position: fixed; property places the element relative to the browser window and keeps it visible even when scrolling. See a full example.
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

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