HTML/CSS MCQ

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

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 HTML attribute is used to specify the width of an image?

A width

B height

C size

D length

A
The ‘width’ attribute is used to specify the width of an image in HTML. For example, <img src="image.jpg" width="200"> sets the image width to 200 pixels.
 

2. Which CSS property is used to create a shadow around an element?

A box-shadow

B shadow-effect

C text-shadow

D drop-shadow

A
The ‘box-shadow’ property adds a shadow around an element. For example, box-shadow: 10px 10px 5px rgba(0,0,0,0.5); creates a shadow 10px offset both horizontally and vertically. See a complete example.
 

3. Which CSS property is used to set the thickness of an element’s borders?

A border-style

B border-width

C border-color

D border-radius

B
The border-width property is used to set the thickness of an element’s borders. For example, border-width: 2px; sets a 2px border.
 
 

4. Which HTML tag is used to define an unordered list?

A <ol>

B <ul>

C <list>

D <li>

B
The <ul> tag is used to define an unordered list, displaying items with bullets. The list items are defined inside the <li> tag.
 

5. Which CSS property hides the scrollbar of an element?

A overflow: hidden;

B visibility: hidden;

C scroll: none;

D display: none;

A
The overflow: hidden; property hides the scrollbar of an element when content overflows. See a complete example.
 

6. What is the purpose of the alt attribute in an <img> tag?

A Display alternative text when the image does not load

B Change the color of the image

C Add a border around the image

D Set the alignment of the image

A
The alt attribute provides an alternative description of an image, useful when the image fails to load.
 
 

7. What does the CSS property z-index do?

A Change the color of the element

B Manage the stacking order of elements

C Change the border thickness

D Add a shadow effect

B
The z-index property controls the stacking order of positioned elements on the Z-axis. An element with a higher z-index will appear above an element with a lower z-index.
 
 

8. What is the role of the href attribute in an <a> tag?

A Define the color of the link text

B Define the web server address

C Define the link text

D Define the destination URL of the link

D
The href attribute in an <a> tag defines the URL or destination of the hyperlink.
 

9. What value of the target attribute opens a link in a new tab or window?

A _self

B _blank

C _top

D _new

B
The target="_blank" attribute opens the link in a new tab or window of the browser.
 
 

10. What value of the CSS property display hides an element while preserving its space in the document flow?

A none

B block

C inline

D visibility: hidden;

D
The value visibility: hidden; hides an element but retains its space in the layout. In contrast, display: none; removes the element from the document flow as well.
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 *