HTML/CSS MCQ

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

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 tag is used to create a link?

A <button>

B <a>

C <link>

D <nav>

B
The HTML tag <a> is used to create a link.
 

2. Which attribute is used to add an image to an HTML page?

A src

B alt

C href

D image

A
In HTML, the src attribute (which stands for “source”) is used in the <img> tag to specify the URL of the image to display on a webpage. Example:

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

3. Which CSS property is used to change the text color?

A background-color

B color

C font-size

D text-color

B
In CSS, the color property is used to set the text color in an HTML element. Example:

p {
  color: red;
}
 
 

4. Which CSS selector targets all <p> elements on an HTML page?

A p {}

B .p {}

C #p {}

D *p {}

A
The CSS selector p {} targets all <p> (paragraph) elements on an HTML page. Any style defined inside the curly braces {} will apply to every <p> tag.
 

5. Which CSS property is used to align items inside a flexbox container?

A align-items

B justify-content

C align-content

D All of the above

D
Each of these properties is used to control the alignment of elements inside a Flexbox container, but they apply on different axes or in different ways. See a full example.
 

6. Which property is used to make a website responsive based on screen size?

A media-query

B @media

C responsive

D viewport

B
Example:

/* Par défaut, styles pour les grands écrans */
body {
  font-size: 18px;
}

@media (max-width: 768px) {
  /* Styles pour les écrans de moins de 768px (tablettes et mobiles) */
  body {
    font-size: 14px;
  }
}
 
 

7. Which HTML tag is used to create a text field in a form?

A <input type="text">

B <textarea>

C <input type="password">

D <input type="button">

A
The tag <input type="text"> is used to create a text field in a form where users can enter data.
 

8. Which CSS property allows an element to be horizontally centered within its parent?

A position: center;

B text-align: center;

C margin: 0 auto;

D align-items: center;

C
When you set margin: 0 auto; on an element with a specified width, it gets horizontally centered within its parent. See a full example.
 

9. Which CSS property sets the spacing between elements in a flex container?

A justify-content

B flex-gap

C align-items

D margin

A
The justify-content property is used to distribute space between items in a flex container. It controls alignment on the main axis (horizontal or vertical). See a full example.
 
 

10. Which CSS property is used to underline links?

Example: Welcome To StackHowTo!

A text-decoration: underline;

B link-decoration: underline;

C decoration: underline;

D underline: true;

A
The text-decoration: underline; property is used to underline the text of an element, like an <a> link.

 

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 *