HTML/CSS MCQ

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

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 display a PDF document in a web page?

A <pdf>

B <embed src="document.pdf">

C <object src="document.pdf">

D <iframe src="document.pdf">

B
The <embed> tag is used to embed a PDF document in a web page, just like <object> and <iframe> can also be used to embed external files.
 

2. How can you write a multi-line comment in HTML?

A <!-- Multi-line comment -->

B /* Multi-line comment */

C // Multi-line comment

D <!-- Multi-line comment (no closing tag)

A
In HTML, comments can span multiple lines and must be closed with –>.
 

3. Which HTML tag is used to create an article section in a blog?

A <article>

B <section>

C <div>

D <aside>

A
The <article> tag is used to define an independent piece of content on a website.
 
 

4. What is the impact of excessive HTML comments on a page?

A Increases performance

B Does not affect performance

C Reduces performance by increasing the file size

D Blocks the execution of the code

C
While comments do not directly affect code execution, a large number of comments can increase the size of the HTML file, which can impact download performance, especially on large pages.
 

5. What is the correct syntax to define a @keyframes animation that moves an element from left to right on the screen?

A @keyframes slide { from { left: 0; } to { left: 100%; } }

B @keyframes slide { from { position: left; } to { position: right; } }

C @keyframes slide { start { left: 0; } end { left: 100%; } }

D @keyframes slide { 0% { left: 0; } 100% { left: 100%; } }

D
CSS animations use @keyframes to define animation steps at different percentages. Here, 0% is the start of the animation and 100% is the end. See a full example.
 

6. Which CSS property is used to apply a filter to an image, such as blur or increased contrast?

A image-filter

B filter

C img-filter

D effect

B
The filter property applies visual effects to an element, such as blur (blur()), contrast (contrast()), or grayscale (grayscale()).
 
 

7. Which HTML tag is used to merge two or more cells in a row of a table?

A <merge>

B <span>

C <td colspan="2">

D <cell merge="2">

C
The colspan attribute allows you to merge multiple cells horizontally in a table row by specifying how many columns the cell should span. See a full example.
 

8. Which CSS background-repeat value allows an image to repeat both horizontally and vertically?

A repeat-x

B repeat-y

C repeat

D no-repeat

C
The repeat value for background-repeat allows the background image to repeat both horizontally and vertically.
 

9. How can you make a column of an HTML table sortable by the user?

A Use a JavaScript plugin to sort the columns.

B Add the sortable attribute to the <th> tags.

C Use a <sort> tag inside the table.

D It is not possible to make a table sortable in pure HTML.

A
HTML does not have native functionality to sort tables dynamically. However, JavaScript libraries like DataTables or scripts can add this functionality.
 
 

10. What is the purpose of the <meta name="description" content="..."> tag in the <head> of an HTML page?

A Provide a description that will appear in the body of the page.

B Help search engines understand the content of the page.

C Define the ID of the page for SEO.

D Create a link to another page of the site.

B
The <meta name="description" content="..."> tag provides a concise description of the page content, used by search engines to display a snippet in search results.
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 *