HTML/CSS MCQs – Multiple Choice Questions and Answers – Part 38
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 do you embed a YouTube video into your HTML page using an <iframe> tag?
A <iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ"></iframe>
B <iframe src="https://www.youtube.com/watch?v=dQw4w9WgXcQ"></iframe>
C <video src="https://www.youtube.com/embed/dQw4w9WgXcQ"></video>
D <iframe src="https://youtube.com/video/dQw4w9WgXcQ"></iframe>
2. What is the effect of the title
attribute in an HTML tag?
A It sets the page title in the browser.
B It displays additional text when the user hovers over the element.
C It adds a caption to an image in an HTML document.
D It defines a title for form content.
3. Which CSS property makes a background fully transparent?
A background-color: rgba(0, 0, 0, 0);
B background-color: transparent;
C opacity: 0;
D A and B
4. How do you add an HTML button that triggers a JavaScript action on click?
A <button onclick="alert('Hello!')">Click here</button>
B <button href="javascript:alert('Hello!')">Click here</button>
C <button action="alert('Hello!')">Click here</button>
D <button href="javascript:void(0)">Click here</button>
5. What is the purpose of the <details>
tag in HTML?
A Display a dropdown menu of links
B Create a modal dialog box
C Create an accordion or collapsible section
D Add extra details to a list
6. Which HTML tag allows you to create an internal link to another section of the same page?
A <a href="#section1">Go to section 1</a>
B <button href="#section1">Go to section 1</button>
C <link href="#section1">Go to section 1</link>
D <a link="#section1">Go to section 1</a>
7. Which HTML tag allows you to include vector graphics directly in a web page?
A <image>
B <canvas>
C <svg>
D <vector>
8. How do you add a mailto link with a pre-filled subject and body?
A <a href="mailto:[email protected]?subject=Hi&body=How are you?">Send email</a>
B <a href="mailto:[email protected]&subject=Hi&body=How are you?">Send email</a>
C <a href="mailto:[email protected]?body=How are you?">Send email</a>
D <a href="mailto:[email protected]?body=Hi">Send email</a>
9. How do you create a link that selects text on an HTML page?
A <a href="#" onclick="document.body.selectAll();">Select all text</a>
B <a href="#" onclick="window.selectAllText();">Select all text</a>
C <a href="javascript:void(0);" onclick="document.body.selectText();">Select all text</a>
D <a href="javascript:void(0);" onclick="window.getSelection().selectAllChildren(document.body);">Select all text</a>
10. How do you add a video with custom controls (e.g., no progress bar) in HTML?
A <video src="video.mp4" controls></video>
B <video src="video.mp4" controlsList="nodownload noprogressbar"></video>
C <video src="video.mp4" autoplay controls></video>
D <video src="video.mp4" controlsList="nodownload"></video>