MCQs Of Class 25: Final Project and Course Review
1. What is the purpose of the <DOCTYPE>
declaration in HTML?
A) It defines the character encoding.
B) It specifies the HTML version.
C) It defines the language of the document.
D) It specifies the title of the webpage.
Answer: B) It specifies the HTML version.
Explanation: The <!DOCTYPE>
declaration tells the browser which version of HTML to use for the page.
2. Which tag is used to define a hyperlink in HTML?
A) <link>
B) <a>
C) <href>
D) <url>
Answer: B) <a>
Explanation: The <a>
tag is used to create hyperlinks in HTML.
3. What is the default value of the position
property in CSS?
A) static
B) relative
C) absolute
D) fixed
Answer: A) static
Explanation: The default position
value in CSS is static
, which means elements are positioned according to the normal flow of the document.
4. Which of the following is the correct syntax to add an external CSS file in HTML?
A) <link rel="stylesheet" href="style.css">
B) <style src="style.css">
C) <css src="style.css">
D) <link href="style.css">
Answer: A) <link rel="stylesheet" href="style.css">
Explanation: The <link>
tag is used to link an external CSS file to an HTML document, and the rel="stylesheet"
specifies the type.
5. Which property is used to change the background color of an element in CSS?
A) background-color
B) color
C) border-color
D) background-image
Answer: A) background-color
Explanation: The background-color
property in CSS is used to set the background color of an element.
6. How do you make a list item appear horizontally using CSS?
A) display: inline-block;
B) display: inline;
C) display: block;
D) list-style-type: none;
Answer: B) display: inline;
Explanation: The display: inline
property is used to make list items appear horizontally.
7. Which CSS property controls the text size of an element?
A) font-family
B) text-align
C) font-size
D) line-height
Answer: C) font-size
Explanation: The font-size
property in CSS controls the size of the text inside an element.
8. What is the default value of the list-style-type
property?
A) circle
B) square
C) none
D) disc
Answer: D) disc
Explanation: The default value of list-style-type
for an unordered list is disc
.
9. Which of the following is the correct syntax for a comment in CSS?
A) <!-- Comment -->
B) // Comment
C) /* Comment */
D) # Comment
Answer: C) /* Comment */
Explanation: In CSS, comments are written using /* */
.
10. What does the display: flex;
property do in CSS?
A) It makes the element inline.
B) It makes the element a flex container.
C) It changes the display of an element to a grid.
D) It hides the element.
Answer: B) It makes the element a flex container.
Explanation: display: flex;
makes an element a flex container, allowing the children to be arranged in a flexible layout.
11. How do you link an external JavaScript file to an HTML document?
A) <script src="script.js"></script>
B) <link href="script.js">
C) <java src="script.js">
D) <js src="script.js">
Answer: A) <script src="script.js"></script>
Explanation: The <script>
tag is used to include an external JavaScript file, and src
specifies the file path.
12. Which property is used to set the space between the border and content in the box model?
A) padding
B) margin
C) border
D) width
Answer: A) padding
Explanation: The padding
property in CSS defines the space between the content of an element and its border.
13. Which HTML tag is used to display images?
A) <image>
B) <pic>
C) <img>
D) <src>
Answer: C) <img>
Explanation: The <img>
tag is used to display images in HTML.
14. What is the correct HTML element for inserting a line break?
A) <break>
B) <line>
C) <br>
D) <lb>
Answer: C) <br>
Explanation: The <br>
tag is used to insert a line break in HTML.
15. Which property is used to change the font of an element in CSS?
A) font-size
B) font-family
C) text-transform
D) font-style
Answer: B) font-family
Explanation: The font-family
property in CSS is used to specify the font of the text in an element.
16. What is the purpose of the target="_blank"
attribute in a hyperlink?
A) It opens the link in a new tab.
B) It opens the link in the same tab.
C) It opens the link in the top frame.
D) It prevents the link from opening.
Answer: A) It opens the link in a new tab.
Explanation: The target="_blank"
attribute makes a hyperlink open in a new browser tab.
17. Which CSS property is used to set the width of an element?
A) width
B) height
C) size
D) margin
Answer: A) width
Explanation: The width
property in CSS defines the width of an element.
18. How do you make text bold using CSS?
A) font-weight: bold;
B) text-weight: bold;
C) font-style: bold;
D) text-transform: bold;
Answer: A) font-weight: bold;
Explanation: The font-weight
property is used to make the text bold in CSS.
19. How can you center-align a block-level element in CSS?
A) text-align: center;
B) margin: 0 auto;
C) position: center;
D) align: center;
Answer: B) margin: 0 auto;
Explanation: The margin: 0 auto;
rule is used to horizontally center a block-level element.
20. Which of the following properties is used to control the space between columns in a CSS grid?
A) column-gap
B) row-gap
C) gap
D) column-spacing
Answer: A) column-gap
Explanation: The column-gap
property sets the space between columns in a grid layout.
21. What does the float
property do in CSS?
A) It allows elements to float to the left or right of their container.
B) It changes the position of an element.
C) It makes elements stick to the screen.
D) It centers elements horizontally.
Answer: A) It allows elements to float to the left or right of their container.
Explanation: The float
property is used to float elements to the left or right of their container, allowing text or other elements to wrap around it.
22. Which HTML element is used to define an unordered list?
A) <list>
B) <ul>
C) <ol>
D) <li>
Answer: B) <ul>
Explanation: The <ul>
tag is used to define an unordered list in HTML.
23. How do you make a list of items appear vertically in HTML?
A) Using <ul>
B) Using <ol>
C) Both <ul>
and <ol>
D) Using <li>
Answer: C) Both <ul>
and <ol>
Explanation: Both <ul>
(unordered list) and <ol>
(ordered list) display list items vertically by default.
24. What is the purpose of the z-index
property in CSS?
A) It sets the opacity of an element.
B) It determines the stacking order of elements.
C) It sets the color of an element.
D) It makes an element visible.
Answer: B) It determines the stacking order of elements.
Explanation: The z-index
property controls the stacking order of elements that overlap.
25. Which tag is used to display a table header?
A) <thead>
B) <th>
C) <tr>
D) <table-header>
Answer: B) <th>
Explanation: The <th>
tag is used to define a header cell in a table.
26. How do you remove the underline from links in CSS?
A) text-decoration: none;
B) text-underline: none;
C) remove-decoration: underline;
D) text-style: none;
Answer: A) text-decoration: none;
Explanation: The text-decoration: none;
property removes the underline from hyperlinks.
27. How do you make an image responsive in CSS?
A) width: 100%;
B) max-width: 100%;
C) height: 100%;
D) width: auto;
Answer: B) max-width: 100%;
Explanation: Setting max-width: 100%
ensures that the image scales with the width of its container while maintaining its aspect ratio.
28. Which property is used to control the space between text characters?
A) letter-spacing
B) word-spacing
C) line-height
D) text-indent
Answer: A) letter-spacing
Explanation: The letter-spacing
property controls the space between text characters.
29. Which of the following is used to set the height of an element in CSS?
A) height
B) width
C) margin
D) padding
Answer: A) height
Explanation: The height
property sets the height of an element in CSS.
30. How do you create a table row in HTML?
A) <tr>
B) <row>
C) <td>
D) <th>
Answer: A) <tr>
Explanation: The <tr>
tag is used to define a row in a table.
31. Which of the following properties is used to set the distance between the content and the border of an element in CSS?
A) margin
B) padding
C) border
D) width
Answer: B) padding
Explanation: The padding
property defines the space between the content and the border of an element.
32. How do you select an element with a specific ID in CSS?
A) .id-name
B) #id-name
C) *id-name
D) id-name
Answer: B) #id-name
Explanation: The #
symbol is used to select an element by its ID in CSS.
33. What is the purpose of the @media
rule in CSS?
A) It allows the use of JavaScript in CSS.
B) It specifies media queries to apply styles based on the device’s characteristics.
C) It sets the background color of an element.
D) It allows the addition of inline CSS.
Answer: B) It specifies media queries to apply styles based on the device’s characteristics.
Explanation: The @media
rule is used to apply styles depending on conditions like screen size.
34. Which HTML tag is used to define a paragraph?
A) <p>
B) <text>
C) <para>
D) <h1>
Answer: A) <p>
Explanation: The <p>
tag is used to define a paragraph in HTML.
35. How do you add a background image to a webpage in CSS?
A) background-image: url('image.jpg');
B) image-background: url('image.jpg');
C) background: url('image.jpg');
D) background-image: src('image.jpg');
Answer: A) background-image: url('image.jpg');
Explanation: The background-image
property is used to set a background image for an element.
36. Which HTML tag is used for a list item?
A) <list>
B) <li>
C) <item>
D) <ol>
Answer: B) <li>
Explanation: The <li>
tag is used to define a list item in an ordered or unordered list.
37. Which property is used to control the space between rows in a CSS grid?
A) row-gap
B) gap
C) column-gap
D) row-spacing
Answer: A) row-gap
Explanation: The row-gap
property is used to set the space between rows in a grid layout.
38. Which of the following is used to hide an element in CSS?
A) display: none;
B) visibility: hidden;
C) visibility: none;
D) both A and B
Answer: D) both A and B
Explanation: Both display: none;
and visibility: hidden;
hide an element, but display: none;
also removes it from the layout.
39. How do you set the font size to 16px in CSS?
A) font: 16px;
B) font-size: 16px;
C) size: 16px;
D) text-size: 16px;
Answer: B) font-size: 16px;
Explanation: The font-size
property is used to set the font size of an element.
40. Which tag is used to create a form in HTML?
A) <form>
B) <input>
C) <textarea>
D) <button>
Answer: A) <form>
Explanation: The <form>
tag is used to create an HTML form.
41. Which property is used to change the text color in CSS?
A) text-color
B) color
C) font-color
D) text-style
Answer: B) color
Explanation: The color
property in CSS is used to change the color of the text.
42. How do you display an element as a block element in CSS?
A) display: inline;
B) display: block;
C) display: flex;
D) display: grid;
Answer: B) display: block;
Explanation: The display: block;
property makes an element a block-level element, occupying the full width.
43. What is the purpose of the box-sizing
property in CSS?
A) It defines the width of an element.
B) It controls how the padding and border are included in the width and height.
C) It makes an element fill the container.
D) It changes the size of an element.
Answer: B) It controls how the padding and border are included in the width and height.
Explanation: The box-sizing
property is used to include padding and border in an element’s total width and height.
44. How do you center a text horizontally in CSS?
A) text-align: center;
B) margin: auto;
C) align: center;
D) display: center;
Answer: A) text-align: center;
Explanation: The text-align: center;
property is used to center text horizontally within its container.
45. Which of the following is the correct way to change the background color of a button in CSS?
A) button-background: red;
B) background-color: red;
C) background: red;
D) color: red;
Answer: B) background-color: red;
Explanation: The background-color
property is used to set the background color of an element.
46. Which CSS property is used to add shadows to text?
A) text-shadow
B) box-shadow
C) shadow
D) font-shadow
Answer: A) text-shadow
Explanation: The text-shadow
property is used to add shadows to text.
47. What does the visibility: hidden;
property do in CSS?
A) It hides the element but retains the space it occupies.
B) It hides the element and removes it from the layout.
C) It makes the element semi-transparent.
D) It makes the element disappear temporarily.
Answer: A) It hides the element but retains the space it occupies.
Explanation: The visibility: hidden;
property hides the element, but it still occupies space in the layout.
48. What does the float: right;
property do?
A) It moves an element to the left of its container.
B) It moves an element to the right of its container.
C) It aligns an element in the center.
D) It makes the element invisible.
Answer: B) It moves an element to the right of its container.
Explanation: The float: right;
property is used to move an element to the right within its containing element.
49. How do you select an element by its class name in CSS?
A) #classname
B) .classname
C) *classname
D) classname
Answer: B) .classname
Explanation: The .
selector is used to select an element by its class name in CSS.
50. Which of the following tags is used to group inline elements in HTML?
A) <div>
B) <section>
C) <span>
D) <article>
Answer: C) <span>
Explanation: The <span>
tag is used to group inline elements without affecting the layout.