HTML/CSS MCQ

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

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 insert a line break?

A <break>

B <br>

C <hr>

D <newline>

B
The <br> tag inserts a line break in the text.
 

2. Which HTML tag is used to define a main section of a page’s content?

A <main>

B <section>

C <div>

D <article>

A
The <main> tag is used to define the main content section of a document, meaning content directly related to the page’s theme. It excludes sections like headers, footers, and sidebars.
 

3. What is the correct syntax to create a linear gradient from red to blue in CSS?

A background: linear-gradient(red, blue);

B background: gradient(linear, red, blue);

C background: linear-color(red to blue);

D background: color-gradient(red, blue);

A
The correct syntax for creating a linear gradient in CSS is linear-gradient(), which takes colors as parameters. Option A is correct. See a complete example.
 
 

4. Which HTML attribute tells the search engine that a page’s content should not be indexed?

A rel="nofollow"

B meta="noindex"

C <meta name="robots" content="noindex">

D <meta name="index" content="false">

C
The attribute <meta name="robots" content="noindex"> tells search engines not to index a page. This technique is commonly used to prevent certain pages from appearing in search results.
 

5. Which HTML tag allows you to embed a Google Map in a webpage?

A <iframe>

B <map>

C <google-map>

D <embed>

A
The <iframe> tag is used to embed external content, like a Google Maps map, into a webpage. The URL of the map is inserted in the src attribute of the iframe.
 

6. Which CSS property is used to define a custom variable for an element’s color?

A --color: blue;

B var(--color, blue);

C color: var(--color);

D All of the above

D
In CSS, you can define a variable with --variable-name and use it with var(--variable-name) to apply the defined value. This makes the CSS code more modular and reusable.
 
 

7. Which HTML tag is used to include Google Fonts in a webpage?

A <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto">

B <style href="https://fonts.googleapis.com/css2?family=Roboto">

C <font-face src="https://fonts.googleapis.com/css2?family=Roboto">

D <link src="https://fonts.googleapis.com/css2?family=Roboto">

A
To include fonts from Google Fonts, use the <link> tag with an href attribute pointing to the font’s URL.
 

8. Which CSS property is used to apply a transformation to an element (e.g., rotation)?

A rotate

B move

C position-transform

D transform

D
The transform property allows various transformations to be applied to an element, such as rotation (rotate()), scaling (scale()), or translation (translate()).
 

9. Which HTML attribute is used to make an image responsive by adjusting its size to the screen?

A width="100%"

B srcset

C responsive="true"

D img-responsive

B
The srcset attribute allows you to specify multiple image sizes so that the browser selects the most appropriate size based on the screen size and resolution.
 
 

10. Which CSS property is used to create columns in a CSS Grid container?

A grid-template-columns

B grid-columns

C grid-columns-template

D column-layout

A
The grid-template-columns property is used to define the structure of columns in a CSS Grid container. It allows you to specify the width of each column.
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 *