HTML/CSS MCQ

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

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 center an element horizontally and vertically within a container using Flexbox?

A align-items: center; and justify-content: center;

B margin: auto;

C display: block;

D position: absolute; and top: 50%; left: 50%;

A
Using Flexbox, to center an element both horizontally and vertically, you need to define align-items: center; (for the vertical axis) and justify-content: center; (for the horizontal axis). See a complete example.
 

2. Which HTML tag is used to create a text area in a form?

A <input type="text">

B <textarea>

C <input type="textarea">

D <fieldarea>

B
The <textarea> tag is used to create a multiline text input area, ideal for large entries like comments or messages. Example:
 
 

3. What is the HTML entity for displaying a double quote (")?

A &quot;

B &gt;

C &lt;

D &amp;

A
The HTML entity for displaying a double quote (") is &quot;. This helps avoid breaking the HTML tag syntax.
 
 

4. What is the correct syntax to define a background color using a hexadecimal value?

A background-color: rgb(255, 0, 0);

B background-color: #ff0000;

C background-color: red;

D background-color: rgba(255, 0, 0, 1);

B
The hexadecimal value #ff0000 corresponds to a red color in CSS. The hexadecimal syntax consists of a # followed by six digits or letters, representing the red, green, and blue values.
 

5. Where is the <meta> tag typically placed in an HTML document?

A At the end of the document, before the </html> tag

B Inside the <body> section

C Inside the <head> section

D Just before the <title> tag

C
The <meta> tag is used to define metadata about the document (such as character encoding or description), and it should be placed inside the <head> section of the HTML document.
 

6. What HTML attribute is used to define the text displayed on a form’s submit button?

A text

B value

C label

D submit

B
The ‘value’ attribute defines the text displayed on a submit button in a form. For example: <input type="submit" value="Send">. Result:
 
 
 

7. Which CSS property is used to create a linear gradient?

A linear-gradient

B background-image

C gradient-color

D color-gradient

A
The linear-gradient() function is used in CSS to create a linear gradient. It can be used with the background-image property, for example: background-image: linear-gradient(to right, red, yellow);. See a complete example.
 

8. What is the correct syntax for embedding an image in an HTML page?

A <img src="image.jpg" alt="Image description">

B <image src="image.jpg">

C <img src="image.jpg">

D <image href="image.jpg">

A
The <img> tag is used to insert images in HTML. The src attribute specifies the image’s path, and alt provides an alternative description for accessibility.
 

9. Which CSS pseudo-class is used to style a link once it has been visited by the user?

A :focus

B :active

C :hover

D :visited

D
The :visited pseudo-class applies to links that have been clicked and visited by the user.
 
 

10. Which HTML tag is used to create a number input field in a form?

A <input type="number">

B <input type="text">

C <input type="range">

D <input type="date">

A
The <input type="number"> element is used to create an input field where the user can enter only numbers.
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 *