HTML/CSS MCQ

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

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 allows you to change the color of an element smoothly when a user hovers over it?

A transition: color 0.5s;

B hover: color 0.5s;

C color: transition 0.5s;

D color: smooth;

A
The transition property defines a smooth animation for property changes. Here, color 0.5s means that the element’s color will change in 0.5 seconds during interaction.
 

2. Which CSS property allows you to rotate an element around its axis by 45 degrees?

A transform: 45deg

B transform-rotate(45deg)

C rotate(45)

D rotate(45deg)

D
The transform property with the rotate() function allows you to rotate an element around its origin point. The value 45deg means a rotation of 45 degrees.
 

3. Which HTML tag is used to create an input field for a phone number?

A <input type="number">

B <input type="tel">

C <input type="phone">

D <input type="text">

B
The type="tel" attribute is used to define a field for entering a phone number. While this field does not automatically validate the number’s structure, it may trigger a specific keyboard on mobile devices.
 
 

4. What does the CSS property position: absolute; do?

A It fixes an element relative to its nearest parent with a defined position.

B It positions an element relative to the browser window.

C It moves an element absolutely within the page.

D It prevents an element from moving inside its container.

A
When an element is positioned with position: absolute;, it is positioned relative to its nearest parent with a defined position (other than static), or relative to the window if no parent is defined.
 

5. Which CSS property allows you to apply a smooth transition on multiple properties of an element?

A transition-properties: all;

B transition-duration: 1s;

C transition-timing: ease-in;

D transition: all 1s ease;

D
The syntax transition: all 1s ease; applies a smooth transition of 1 second on all the CSS properties of the element, and ease defines the timing function for the animation.
 

6. Which HTML attribute is used to group multiple options in a form for better organization?

A fieldset

B group

C optgroup

D selectgroup

C
The optgroup attribute is used inside a <select> element to group options under a single label, improving the organization of the dropdown list. See a complete example.
 
 

7. Which CSS selector targets all <p> elements inside an element with the class .content?

A .content > p

B .content p

C p.content

D #content p

B
The .content p selector targets all <p><p> elements inside an element with the class .content. If you use .content > p, it would only target <p><p> elements that are direct children of .content.
 

8. Which HTML entity displays the “©” symbol?

A &copy;

B &symbol;

C &copy-symbol;

D &right-symbol;

A
The HTML entity &copy; is used to display the copyright symbol “©”. This ensures compatibility across all browsers and encoding systems.
 

9. Which CSS property adds a text shadow to an element?

A text-shadow

B box-shadow

C shadow-text

D shadow-box

A
The text-shadow property allows you to add a shadow to text, defining its position, blur, and color.
 
 

10. Which HTML attribute is used to specify the width and height of an image before it is fully loaded?

A srcset

B width and height

C img-size

D loading="lazy"

B
The width and height attributes are used to define the dimensions of an HTML image, allowing browsers to reserve the necessary space before the image is fully loaded.
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 *