HTML/CSS MCQs – Multiple Choice Questions and Answers – Part 39
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 create a page background with an image that repeats across the entire page?
A background: url('pattern.png') repeat;
B background-repeat: no-repeat; background-image: url('pattern.png');
C background: url('pattern.png') fixed;
D background-image: repeat('pattern.png');
2. How do you create a link that downloads a file when clicked?
A <a href="file.pdf" download>Download File</a>
B <a href="file.pdf" target="_blank" download>Download File</a>
C <a href="file.pdf" target="_self" download>Download File</a>
D <a href="file.pdf" rel="download">Download File</a>
3. How can you improve the accessibility of a button with ARIA in HTML?
A <button aria-label="Send message">Send</button>
B <button aria-hidden="true">Send</button>
C <button aria-live="polite">Send</button>
D <button aria-label="Submit">Submit</button>
4. Which CSS property allows you to create a horizontal scrolling effect for text?
A white-space: nowrap; overflow: scroll;
B overflow-x: scroll; white-space: nowrap;
C overflow-x: auto; white-space: normal;
D overflow: hidden; white-space: nowrap;
5. How do you create a link to download an image in HTML?
A <a href="image.jpg" download="image.jpg">Download</a>
B <a href="image.jpg" target="_blank" download>Download</a>
C <a href="image.jpg" download>Download</a>
D <a href="image.jpg" target="_self" download="image.jpg">Download</a>
6. How do you create a fixed background on the entire page that doesn’t scroll with the content?
A background-attachment: static;
B background-attachment: scroll;
C background-attachment: absolute;
D background-attachment: fixed;
7. How do you create a numbered list using letters in HTML?
A <ol type="a"><li>First item</li></ol>
B <ol type="A"><li>First item</li></ol>
C <ul type="A"><li>First item</li></ul>
D <ol type="alpha"><li>First item</li></ol>
8. How do you create a text area that limits the number of characters in HTML?
A <textarea maxlength="100"></textarea>
B <input type="text" maxlength="100">
C <input type="text" limit="100">
D <textarea limit="100"></textarea>
9. When is it better to use CSS Grid over Flexbox?
A Grid is better for one-dimensional layouts (horizontal or vertical).
B Flexbox is better for complex layouts with multiple rows and columns.
C Grid is more suitable for two-dimensional layouts like rows and columns.
D Flexbox should only be used for centering elements within a container.
10. Which HTML attribute specifies the method used to submit a form?
A action
B submit
C enctype
D method