HTML/CSS MCQ

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

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 name of a group of radio buttons?

A id

B name

C value

D group

B
The ‘name’ attribute is used to specify the group a radio button belongs to. This ensures that only one radio button from that group can be selected at a time. Example:

<input type="radio" name="fruit" value="apple"> Apple
<input type="radio" name="fruit" value="banana"> Banana
<input type="radio" name="fruit" value="orange"> Orange

All radio buttons have the same name “fruit”, which groups them together. This ensures that only one button from this group can be selected at a time.

 

2. Which HTML tag is used to embed an audio file?

A <audio>

B <media>

C <sound>

D <music>

A
The <audio> tag is used to embed audio content in an HTML page. You can also add attributes like “controls” to show playback controls.
 

3. How do you create a button that changes from red to green when hovered?

A button:hover { color: green; }

B button:hover { background-color: green; }

C button:hover { text-color: green; }

D button:hover { border-color: green; }

B
The :hover pseudo-class lets you apply styles when a user hovers over an element. Here, background-color changes the background color of the button.
 
 

4. What is the role of the flex-grow property in CSS?

A Change content size

B Determine how much space an item should take up in a flex container

C Adjust alignment of flex items

D Change the background color of a flex item

B
The flex-grow property defines how much a flex item should grow relative to others in the flex container. The higher the value, the more space the item takes up. See a full example.
 

5. How do you make an element completely transparent using CSS?

A opacity: 1;

B visibility: transparent;

C opacity: 0;

D display: none;

C
opacity: 0; makes an element fully transparent while still occupying space in the layout, unlike display: none; which removes the element entirely from the document flow.
 

6. How do you add a background image to an element in CSS?

A background-image: url("image.jpg");

B image-background: url("image.jpg");

C background: img("image.jpg");

D image-src: url("image.jpg");

A
The background-image property is used to apply a background image to an element.
 
 

7. If you want an element to stay visible at the top of the page even when scrolling, which CSS style would you apply?

A position: sticky; top: 0;

B position: fixed; top: 0;

C position: relative;

D position: absolute;

B
position: fixed; makes an element stay fixed in place on the screen during scrolling. With top: 0;, it remains at the top of the viewport.
 

8. If you want the content of a page to automatically adjust when the screen gets smaller, which approach would you use?

A Use fixed units (px)

B Use position: absolute;

C Use media queries

D Use display: none;

C
Media queries let you apply CSS rules based on device characteristics like screen width, making responsive layouts possible.
 

9. How do you create a background image that only repeats vertically and not horizontally?

A background-repeat: no-repeat;

B background-repeat: repeat-y;

C background-repeat: repeat-x;

D background-repeat: repeat;

B
The background-repeat property controls how the background image repeats. Using repeat-y makes it repeat only vertically, while repeat-x repeats it horizontally.
 
 

10. Which HTML tag is used to define a definition list?

A <ol>

B <ul>

C <dl>

D <list>

C
The <dl> tag is used to define a definition list. Inside it, use <dt> for the term and <dd> for the definition. 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 *