HTML/CSS MCQ

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

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. How are custom fonts defined using CSS?

A @font-face

B It is not possible to define custom fonts.

C Using the src attribute.

D None of these answers

A
We can define our own custom fonts using the @font-face CSS rule. Example:

@font-face {
  font-family: maPolicePerso;
  src: url(sansation_light.woff);
}
 

2. What will be the width of the div element below?
div {
  width: 310px;
  padding: 20px;
  border: 5px solid red;
  margin: 0;
}

A 310px

B 350px

C 360px

D None of these answers

C
310 px (width) + 20 * 2 px (left + right padding) + 5 * 2 px (left + right border) + 0px (margin) = 360px.
 

3. Which of the following properties is used to align text in CSS?

A text-align

B text-alignment

C text

D text-position

A
The text-align property specifies text alignment in CSS. See an example.
 
 

4. Which of the following approaches is correct for making a table responsive?

A overflow-x: auto

B overflow-x: none

C Both A and B

D None of these answers

A
Wrapping a <table> element with a container (like <div>) and applying overflow-x: auto will make it responsive.
 

5. What are the uses of CSS pseudo-elements?

A Style specific parts of an element.

B Style the first letter or line of an element.

C Insert content before or after the element.

D All answers are correct

D
A CSS pseudo-element is used to style specific parts of an element.For example, it can be used to:

  • Style the first letter or line of an element
  • Insert content before or after the element’s content

Example:

p::first-line {  color: #ff0000;  font-variant: small-caps;}

See the full example here.

 

6. How do you select elements with a specific attribute in CSS?

A Selector [attribute]

B Selector [property]

C Both A and B

D None of these answers

A
The [attribute] selector is used to select elements with a specified attribute. See an example.
 
 

7. What is the parameter of the calc() function in CSS?

A A sentence

B A number

C A mathematical expression

D None of these answers

C
The calc() function takes a mathematical expression as a parameter and returns its value. See an example.
 

8. How do you give more importance to a property/value than normal?

A important

B !important

C strong

D blod

B
The !important rule in CSS is used to give more importance to a property/value than normal.In fact, if you use the !important rule, it overrides ALL previous style rules for that specific property on that element. See an example.
 

9. Which CSS property specifies the background painting area?

A background-size

B background-clip

C background-image

D background-color

B
The background-clip property in CSS specifies the painting area of the background. See an example.
 
 

10. Which function is used to insert the values of a CSS variable?

A var()

B varchar()

C rand()

D insert()

A
The var() function is used to insert the values of a CSS variable. See an 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 *