HTML/CSS MCQ

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

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 unit is relative to the font size of the parent element?

A em

B px

C rem

D pt

A
The ’em’ unit is relative to the font size of the parent element. For example, if the parent’s font size is 16px, 1em will equal 16px.
 

2. Which CSS property is used to move an element based on its relative positioning?

A left, top

B transform

C translate

D position

A
The ‘left’ and ‘top’ properties are used to move an element when its ‘position’ property is set to ‘relative’, ‘absolute’, or ‘fixed’.
 

3. Which CSS property is used to change the color of an unvisited link?

A a:visited

B a:link

C a:hover

D a:focus

B
The a:link pseudo-class is used to define the style of a link that has not yet been visited. You can specify different colors for each state (:link, :visited, :hover, :active).
 
 

4. Which CSS property sets the duration of an animation?

A animation-duration

B animation-time

C transition-duration

D animation-delay

A
The animation-duration property sets the total time the animation should run before completing. See a complete example.
 

5. Which HTML tag is used to create a table row?

A <td>

B <tr>

C <th>

D <table>

B
The <tr> tag is used to create a row in an HTML table.
 

6. Which CSS property makes a container flexible?

A flexbox

B display: flex;

C flex: auto;

D container-flex;

B
The display: flex; property is used to define an element as a flex container, enabling flexible positioning of its child elements. See a complete example.
 
 

7. Which CSS property horizontally centers an element inside a flex container?

A align-items: center;

B justify-content: center;

C text-align: center;

D margin: auto;

B
The justify-content: center; property is used inside a flex container to horizontally align its child elements at the center. See a complete example.
 

8. Which CSS property creates a smooth transition when an element changes state?

A transition

B animation

C transform

D move

A
The transition property allows you to add a smooth effect when an element’s style changes — for example, in color or size — over a set duration.
 

9. Which attribute is used in the <input> tag to define the field type (such as text, password, button, etc.)?

A type

B field

C value

D name

A
The type attribute of the <input> tag specifies the type of field to display (e.g., text, password, submit, etc.). See a complete example.
 
 

10. Which CSS property defines the space between lines of text?

A line-height

B letter-spacing

C text-align

D text-spacing

A
The line-height property sets the spacing between lines of text within an element. See a complete 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 *