MCQs Of Class 21: Project - Enhancing the Personal Web Page
1. What is the correct HTML element to define a navigation menu?
a) <nav>
b) <menu>
c) <navigation>
d) <section>
Answer: a) <nav>
Explanation: The <nav>
element is used to define a section of a webpage for navigation links.
2. Which attribute is used to provide a destination for a link in an anchor (<a>
) tag?
a) href
b) src
c) alt
d) action
Answer: a) href
Explanation: The href
attribute in the <a>
tag specifies the URL or the target location of the link.
3. Which CSS property is used to change the color of a hyperlink when hovered over?
a) text-decoration
b) background-color
c) color
d) hover-color
Answer: c) color
Explanation: The color
property is used to change the color of text, including hyperlinks. To change the color when hovered, you can use the :hover
pseudo-class in CSS.
4. Which HTML tag is used to include an image in a webpage?
a) <image>
b) <img>
c) <picture>
d) <src>
Answer: b) <img>
Explanation: The <img>
tag is used to embed images on a webpage. It requires the src
attribute to specify the image path.
5. How do you make an image responsive using CSS?
a) img { width: 100%; height: auto; }
b) img { width: auto; height: 100%; }
c) img { width: 50%; height: 50%; }
d) img { max-width: 100%; height: 100%; }
Answer: a) img { width: 100%; height: auto; }
Explanation: To make an image responsive, set its width to 100% and height to auto to preserve its aspect ratio.
6. Which HTML element is used to embed audio in a webpage?
a) <audio>
b) <sound>
c) <media>
d) <music>
Answer: a) <audio>
Explanation: The <audio>
tag is used to embed audio files on a webpage. It can have attributes like controls
, autoplay
, and loop
.
7. Which CSS property is used to change the border radius of an image?
a) border-radius
b) border
c) box-radius
d) corner-radius
Answer: a) border-radius
Explanation: The border-radius
property in CSS is used to round the corners of an element, including images.
8. How can you create a form field to input a user's email address in HTML?
a) <input type="email">
b) <input type="text">
c) <textarea>
d) <input type="password">
Answer: a) <input type="email">
Explanation: The type="email"
attribute is used for email input fields in HTML forms. It automatically validates the email format.
9. How do you align items horizontally in a navigation bar using CSS?
a) nav ul { text-align: center; }
b) nav ul { display: block; }
c) nav ul { list-style-type: none; }
d) nav ul { display: flex; }
Answer: d) nav ul { display: flex; }
Explanation: Using display: flex
on the ul
element in CSS aligns the list items horizontally.
10. What is the function of the <video>
tag in HTML?
a) To add a YouTube video
b) To display an image
c) To add a video file
d) To play audio files
Answer: c) To add a video file
Explanation: The <video>
tag is used to embed a video on a webpage.
11. Which CSS property is used to change the background color of a webpage?
a) color
b) background
c) background-color
d) color-background
Answer: c) background-color
Explanation: The background-color
property is used to set the background color of an element, including the entire page.
12. What does the scroll-behavior: smooth;
CSS rule do?
a) Makes the page content scroll faster
b) Enables smooth scrolling when navigating between sections
c) Prevents scrolling in mobile view
d) Makes the content scroll continuously
Answer: b) Enables smooth scrolling when navigating between sections
Explanation: The scroll-behavior: smooth;
rule adds smooth scrolling when you click on anchor links that jump to different sections.
13. What does the max-width: 100%
CSS rule do to an image?
a) Forces the image to have a maximum width of 100px
b) Makes the image cover its container width
c) Scales the image to its original size
d) Ensures the image does not exceed the container width
Answer: d) Ensures the image does not exceed the container width
Explanation: The max-width: 100%
rule ensures the image does not exceed the width of its container, making it responsive.
14. Which HTML tag is used to create a section of a webpage?
a) <div>
b) <section>
c) <article>
d) <header>
Answer: b) <section>
Explanation: The <section>
tag is used to define sections in a webpage, typically with a specific heading or topic.
15. What is the correct way to apply an external CSS stylesheet to an HTML page?
a) <style src="styles.css">
b) <link rel="stylesheet" href="styles.css">
c) <css src="styles.css">
d) <stylesheet href="styles.css">
Answer: b) <link rel="stylesheet" href="styles.css">
Explanation: The <link>
tag is used to link an external CSS stylesheet to an HTML document.
16. Which CSS property is used to add spacing between the text and its border inside an element?
a) padding
b) margin
c) border-spacing
d) text-spacing
Answer: a) padding
Explanation: The padding
property is used to add space between the content of an element and its border.
17. How do you define a hyperlink in HTML?
a) <link href="url">
b) <a link="url">
c) <a href="url">
d) <hyperlink href="url">
Answer: c) <a href="url">
Explanation: The <a>
tag is used to define hyperlinks, and the href
attribute specifies the URL.
18. Which CSS property is used to change the font size of text?
a) text-size
b) font-size
c) font-weight
d) size
Answer: b) font-size
Explanation: The font-size
property in CSS is used to set the size of the text in an element.
19. Which HTML tag is used to define a footer in a webpage?
a) <footer>
b) <div>
c) <section>
d) <aside>
Answer: a) <footer>
Explanation: The <footer>
tag is used to define the footer of a webpage, typically containing copyright and contact information.
20. How do you center-align text in CSS?
a) text-align: center;
b) align: center;
c) center-text: true;
d) text-align: middle;
Answer: a) text-align: center;
Explanation: The text-align: center;
property is used to center-align text within its container.
21. What is the correct way to create a clickable button in HTML?
a) <button action="submit">Click Me</button>
b) <button onclick="submit()">Click Me</button>
c) <a href="submit.html">Click Me</a>
d) <button>Click Me</button>
Answer: d) <button>Click Me</button>
Explanation: The <button>
tag is used to create a clickable button in HTML.
22. Which CSS property is used to add space outside an element?
a) padding
b) border
c) margin
d) spacing
Answer: c) margin
Explanation: The margin
property adds space outside an element's border.
23. Which HTML tag is used to create a hyperlink that links to another webpage?
a) <link>
b) <a>
c) <button>
d) <iframe>
Answer: b) <a>
Explanation: The <a>
tag is used to create hyperlinks to other pages or resources.
24. What does the target="_blank"
attribute in an anchor tag do?
a) Opens the link in the same tab
b) Opens the link in a new tab
c) Opens the link in a different window
d) Opens the link in an iframe
Answer: b) Opens the link in a new tab
Explanation: The target="_blank"
attribute opens the linked resource in a new tab or window.
25. What is the purpose of using <section>
in HTML?
a) To group content into sections with headers
b) To create a page header
c) To display images
d) To display video content
Answer: a) To group content into sections with headers
Explanation: The <section>
tag is used to group content into logical sections, often with headings.
26. Which CSS property controls the text color?
a) color
b) font-color
c) text-color
d) background-color
Answer: a) color
Explanation: The color
property controls the color of text within an element.
27. How do you create a list in HTML?
a) <ol>
b) <ul>
c) <li>
d) All of the above
Answer: d) All of the above
Explanation: <ul>
creates an unordered list, <ol>
creates an ordered list, and <li>
defines list items.
28. Which CSS property is used to change the background color of an element?
a) color
b) background-color
c) background
d) bg-color
Answer: b) background-color
Explanation: The background-color
property changes the background color of an element.
29. Which HTML tag is used to define the largest heading?
a) <h1>
b) <h2>
c) <h3>
d) <h6>
Answer: a) <h1>
Explanation: The <h1>
tag defines the largest heading in HTML.
30. What does the text-decoration: underline;
CSS property do?
a) Changes the text to bold
b) Makes the text italic
c) Adds a line below the text
d) Changes the text color
Answer: c) Adds a line below the text
Explanation: The text-decoration: underline;
property adds a line under the text.
31. Which CSS property is used to set the font style of text?
a) font-style
b) text-font
c) font
d) text-style
Answer: a) font-style
Explanation: The font-style
property is used to set the style of the font, such as italic or normal.
32. How do you add a comment in HTML?
a) <!-- This is a comment -->
b) // This is a comment
c) /* This is a comment */
d) # This is a comment
Answer: a) <!-- This is a comment -->
Explanation: In HTML, comments are added using the <!-- -->
syntax.
33. How do you include an external JavaScript file in an HTML document?
a) <script href="file.js">
b) <link href="file.js">
c) <script src="file.js"></script>
d) <script file="file.js">
Answer: c) <script src="file.js"></script>
Explanation: The <script>
tag with the src
attribute is used to include an external JavaScript file.
34. What does the opacity
property in CSS do?
a) Changes the visibility of an element
b) Changes the transparency of an element
c) Adjusts the size of an element
d) Hides the element
Answer: b) Changes the transparency of an element
Explanation: The opacity
property in CSS controls the transparency of an element, ranging from 0
(completely transparent) to 1
(completely opaque).
35. Which HTML tag is used to display a table?
a) <table>
b) <tr>
c) <td>
d) <thead>
Answer: a) <table>
Explanation: The <table>
tag is used to define a table in HTML.
36. What is the correct way to link to an external CSS file?
a) <css href="style.css">
b) <link rel="stylesheet" href="style.css">
c) <style href="style.css">
d) <style src="style.css">
Answer: b) <link rel="stylesheet" href="style.css">
Explanation: The <link>
tag with rel="stylesheet"
is used to link an external CSS file to an HTML document.
37. Which HTML tag is used to define an input field for a form?
a) <button>
b) <input>
c) <textarea>
d) <form>
Answer: b) <input>
Explanation: The <input>
tag is used to create input fields in a form.
38. How do you create a table row in HTML?
a) <tr>
b) <th>
c) <td>
d) <table>
Answer: a) <tr>
Explanation: The <tr>
tag defines a table row in HTML.
39. How do you add a class to an HTML element?
a) class="classname"
b) addclass="classname"
c) className="classname"
d) class: classname
Answer: a) class="classname"
Explanation: The class
attribute is used to assign a class to an HTML element.
40. What does the border
CSS property do?
a) Adds space between elements
b) Adds a border around an element
c) Changes the background color
d) Changes the width of an element
Answer: b) Adds a border around an element
Explanation: The border
property is used to define a border around an element, with width, style, and color.
41. Which CSS property is used to display an element as a block?
a) display: block;
b) display: inline;
c) display: flex;
d) display: none;
Answer: a) display: block;
Explanation: The display: block;
property is used to display an element as a block-level element.
42. How do you add a comment in CSS?
a) // This is a comment
b) <!-- This is a comment -->
c) /* This is a comment */
d) # This is a comment
Answer: c) /* This is a comment */
Explanation: In CSS, comments are written using the /* */
syntax.
43. Which tag is used to group elements in HTML for styling?
a) <section>
b) <div>
c) <article>
d) <header>
Answer: b) <div>
Explanation: The <div>
tag is used to group elements for styling or layout purposes.
44. What is the correct syntax for defining a color in CSS using hexadecimal notation?
a) color: #ff0000;
b) color: red;
c) color: rgb(255, 0, 0);
d) color: #rgb(255, 0, 0);
Answer: a) color: #ff0000;
Explanation: The hexadecimal color #ff0000
represents red.
45. Which HTML tag is used for creating a list item?
a) <ul>
b) <li>
c) <ol>
d) <list>
Answer: b) <li>
Explanation: The <li>
tag is used to define a list item inside either an ordered or unordered list.
46. What is the purpose of the z-index
property in CSS?
a) To define the font size
b) To control the stacking order of elements
c) To change the background color
d) To define the font family
Answer: b) To control the stacking order of elements
Explanation: The z-index
property controls the stacking order of positioned elements.
47. What is the function of the box-shadow
property in CSS?
a) Adds a shadow effect around an element
b) Changes the color of the element's border
c) Changes the background of the element
d) Adds a glowing effect to the text
Answer: a) Adds a shadow effect around an element
Explanation: The box-shadow
property is used to add shadow effects around elements.
48. Which attribute is used in the <img>
tag to specify the image source?
a) src
b) alt
c) href
d) link
Answer: a) src
Explanation: The src
attribute specifies the source of the image in the <img>
tag.
49. How can you make a list of items that appear with bullet points in HTML?
a) <ol>
b) <ul>
c) <li>
d) <list>
Answer: b) <ul>
Explanation: The <ul>
tag is used to create an unordered list, which appears with bullet points.
50. What is the correct HTML tag to define a form?
a) <form>
b) <input>
c) <textarea>
d) <button>
Answer: a) <form>
Explanation: The <form>
tag is used to define an HTML form for user input.