0% found this document useful (0 votes)
34 views150 pages

CSE326 Unit 1 - 6 MCQ

efsewdf fesewdfv fe

Uploaded by

wanirakib58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views150 pages

CSE326 Unit 1 - 6 MCQ

efsewdf fesewdfv fe

Uploaded by

wanirakib58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 150

UNIT 1 MCQ

1. What is the purpose of the <head> element in an HTML document?

A. Defines the main content of the document

B. Contains metadata about the document

C. Specifies the document title

D. Creates a new section in the document

Answer: B. Contains metadata about the document

2. Which HTML tag is used to create a line break within text?

A. <lb>

B. <br>

C. <break>

D. <newline>

Answer: B. <br>

3. What is the function of the <cite> tag in HTML?

A. It creates a citation for a block of text.

B. It defines a section in the document.

C. It adds emphasis to text.

D. It sets the font style for a block of text.

Answer: A. It creates a citation for a block of text.

4. Which HTML tag is used to define the root element of an HTML document?

A. <html>
B. <root>

C. <main>

D. <doctype>

Answer: A. <html>

5. What is the purpose of the <meta> tag in the <head> section?

A. Defines a new metadata section

B. Specifies the main content of the document

C. Provides information about the author

D. Contains metadata about the HTML document

Answer: D. Contains metadata about the HTML document

6. Which HTML tag is used to create an unordered list?

A. <ol>

B. <li>

C. <ul>

D. <list>

Answer: C. <ul>

7. What is the purpose of the <hr> tag in HTML?

A. Creates a hyperlink

B. Defines a horizontal rule

C. Specifies the document title

D. Adds emphasis to text

Answer: B. Defines a horizontal rule


8. Which attribute is used to define the character encoding for an HTML document?

A. encoding

B. charset

C. text-type

D. lang

Answer: B. charset

9. In HTML, which tag is used to insert an image?

A. <img>

B. <picture>

C. <image>

D. <media>

Answer: A. <img>

10. What is the purpose of the <dl> tag in HTML?

A. Defines a description list

B. Creates a definition for a term

C. Specifies a division or section

D. Declares a new list

Answer: A. Defines a description list

11. Which HTML tag is used to create a hyperlink?

A. <link>

B. <a>

C. <href>
D. <hyper>

Answer: B. <a>

12. What does the HTML acronym stand for?

A. HyperText Markup Language

B. High-Text Multilayered Language

C. HyperTransfer Markup Language

D. Hierarchical Text Management Language

Answer: A. HyperText Markup Language

13. Which tag is used to define a paragraph in HTML?

A. <para>

B. <p>

C. <paragraph>

D. <text>

Answer: B. <p>

14. What is the purpose of the <blockquote> tag in HTML?

A. Creates a block-level division

B. Defines a block of text as a quotation

C. Formats text as a code block

D. Adds emphasis to text within a block

Answer: B. Defines a block of text as a quotation

15. Which tag is used to define the main content of an HTML document?
A. <content>

B. <main>

C. <body>

D. <section>

Answer: C. <body>

16. In HTML, what is the purpose of the <sup> tag?

A. Specifies subscript text

B. Adds emphasis to text

C. Defines superscript text

D. Creates a strike-through effect

Answer: C. Defines superscript text

17. What HTML tag is used to define a table?

A. <table>

B. <grid>

C. <tab>

D. <tbl>

Answer: A. <table>

18. Which HTML tag is used to create an ordered list?

A. <ol>

B. <li>

C. <ul>

D. <list>

Answer: A. <ol>
19. What is the purpose of the alt attribute in the <img> tag?

A. Defines alternative text for the image

B. Sets the alignment of the image

C. Specifies the image source

D. Adds a border around the image

Answer: A. Defines alternative text for the image

20. Which HTML tag is used to emphasize text without implying any importance or relevance?

A. <strong>

B. <em>

C. <bold>

D. <italics>

Answer: B. <em>

21. What is the purpose of the HTML <footer> tag?

A. It defines a header for a document.

B. It specifies the main content of the document.

C. It creates a footer for a document.

D. It sets the font style for a section of text.

Answer: C. It creates a footer for a document.

22. Which HTML tag is used to create a hyperlink that opens in a new tab or window?

A. <a target="_blank">

B. <link new>
C. <hyper new>

D. <openlink>

Answer: A. <a target="_blank">

23. In HTML, what does the <nav> tag represent?

A. It defines a navigation menu.

B. It specifies a new section in the document.

C. It creates a list of navigation links.

D. It sets the font color for text.

Answer: A. It defines a navigation menu.

24. What is the purpose of the HTML <aside> tag?

A. It defines a section in the document.

B. It creates an area for supplementary content.

C. It sets the font size for a block of text.

D. It specifies a hyperlink.

Answer: B. It creates an area for supplementary content.

25. Which HTML tag is used to define a section in a document that is not the main content?

A. <section>

B. <main>

C. <div>

D. <article>

Answer: A. <section>

26. What is the purpose of the colspan attribute in an HTML table?


A. It specifies the column width.

B. It sets the background color of a cell.

C. It defines the number of columns a cell should span.

D. It creates a border around a cell.

Answer: C. It defines the number of columns a cell should span.

27. Which HTML tag is used to define a definition list term?

A. <def>

B. <dt>

C. <dlterm>

D. <definition>

Answer: B. <dt>

28. What does the placeholder attribute in an HTML form represent?

A. It specifies the default value for an input field.

B. It sets the font style of the form.

C. It defines the size of the form.

D. It creates a placeholder image in the form.

Answer: A. It specifies the default value for an input field.

29. Which HTML tag is used to define the base font size for the entire document?

A. <basefont>

B. <fontsize>

C. <base>

D. <size>
Answer: A. <basefont>

30. What is the purpose of the HTML attribute rowspan in a table?

A. It specifies the row height.

B. It defines the number of rows a cell should span.

C. It sets the border style for a row.

D. It creates a background color for a row.

Answer: B. It defines the number of rows a cell should span.

31. Which HTML tag is used to create an ordered list item?

A. <il>

B. <li>

C. <ol>

D. <listitem>

Answer: B. <li>

32. What is the purpose of the HTML <abbr> tag?

A. It defines an abbreviation or acronym.

B. It creates an absolute link.

C. It sets the background color of a block.

D. It specifies the alignment of text.

Answer: A. It defines an abbreviation or acronym.

33. In HTML, what does the <strong> tag represent?

A. It indicates text that should be emphasized.


B. It creates a strong emphasis on text.

C. It sets the font weight to bold.

D. It defines a new section in the document.

Answer: C. It sets the font weight to bold.

34. Which HTML tag is used to define a horizontal rule with a thematic break?

A. <break>

B. <rule>

C. <hr>

D. <line>

Answer: C. <hr>

35. What is the purpose of the HTML <mark> tag?

A. It defines a highlighted or marked portion of text.

B. It creates a navigation link.

C. It specifies the main content of the document.

D. It sets the font style for a block of text.

Answer: A. It defines a highlighted or marked portion of text.

36. Which HTML tag is used to define a subscript text?

A. <sub>

B. <sup>

C. <subscript>

D. <lower>

Answer: A. <sub>
37. In HTML, what is the purpose of the nowrap attribute in a table cell?

A. It prevents text from wrapping to the next line.

B. It sets the width of the cell.

C. It specifies the number of characters allowed in the cell.

D. It creates a new row in the table.

Answer: A. It prevents text from wrapping to the next line.

38. Which HTML tag is used to define the document's character set encoding?

A. <charset>

B. <encoding>

C. <meta charset="">

D. <charcode>

Answer: C. <meta charset="">

39. What is the purpose of the HTML <article> tag?

A. It creates an article section within the document.

B. It defines an article title.

C. It specifies a hyperlink.

D. It sets the font color for a block of text.

Answer: A. It creates an article section within the document.

40. Which attribute is used to define the source URL of an external script in HTML?

A. script

B. source

C. src
D. link

Answer: C. src

41. What does the HTML attribute alt in the <img> tag provide?

A. Alternative text for the image

B. Alignment of the image

C. Altitude of the image

D. Adjustment for image size

Answer: A. Alternative text for the image

42. Which HTML tag is used to define a hyperlink that links to an email address?

A. <email>

B. <a>

C. <link>

D. <mailto>

Answer: B. <a>

43. What is the purpose of the HTML <figure> tag?

A. Defines a figure or an image

B. Creates a new figure in the document

C. Sets the size of the text

D. Specifies a caption for an image

Answer: A. Defines a figure or an image

44. In HTML, what does the <code> tag represent?


A. It defines a code block.

B. It specifies the color of the text.

C. It creates a new section in the document.

D. It defines a code comment.

Answer: A. It defines a code block.

45. Which HTML tag is used to define the header for a group of columns in a table?

A. <thead>

B. <header>

C. <th>

D. <colgroup>

Answer: A. <thead>

46. What is the purpose of the HTML attribute colgroup in a table?

A. Specifies the column width

B. Defines a group of columns

C. Sets the background color of a column

D. Creates a border around a column

Answer: B. Defines a group of columns

47. In HTML, what does the <figcaption> tag represent?

A. Specifies a figure or an image

B. Defines a caption for a figure

C. Sets the font style for a block of text

D. Creates a new section in the document

Answer: B. Defines a caption for a figure


48. Which HTML tag is used to define a navigation link within a navigation bar?

A. <navlink>

B. <link>

C. <navbar>

D. <a>

Answer: D. <a>

49. What is the purpose of the HTML <time> tag?

A. Specifies a time element in the document

B. Sets the document creation time

C. Creates a countdown timer

D. Defines a time zone for the document

Answer: A. Specifies a time element in the document

50. Which HTML tag is used to define a horizontal rule with a thematic break and a caption?

A. <hr>

B. <line>

C. <rule>

D. <hr withcaption>

Answer: D. <hr withcaption>

51. What is the purpose of the HTML <fieldset> tag?

A. Defines a field in a form

B. Creates a new section in the document


C. Groups related form elements together

D. Specifies a font size for text

Answer: C. Groups related form elements together

52. In HTML, which attribute is used to provide a brief description of an item within a list?

A. desc

B. title

C. info

D. description

Answer: B. title

53. What does the HTML attribute colspan in a table cell indicate?

A. It specifies the color of the cell.

B. It defines the number of columns a cell should span.

C. It sets the font style for text in the cell.

D. It creates a border around the cell.

Answer: B. It defines the number of columns a cell should span.

54. Which HTML tag is used to create an interactive button in a form?

A. <input>

B. <button>

C. <submit>

D. <action>

Answer: B. <button>

55. In HTML, what does the <datalist> tag represent?


A. Defines a description list

B. Specifies a list of options for an <input> element

C. Creates a data table

D. Sets the font size for a block of text

Answer: B. Specifies a list of options for an <input> element

56. What is the purpose of the HTML <select> tag?

A. It defines a section in the document.

B. It creates a drop-down list.

C. It sets the font color for text.

D. It specifies a hyperlink.

Answer: B. It creates a drop-down list.

57. Which HTML tag is used to create a checkbox in a form?

A. <check>

B. <checkbox>

C. <input type="checkbox">

D. <select>

Answer: C. <input type="checkbox">

58. What is the purpose of the HTML <progress> tag?

A. Defines a progress bar

B. Creates a new section in the document

C. Sets the font style for a block of text

D. Specifies a navigation link


Answer: A. Defines a progress bar

59. In HTML, which tag is used to define a keyboard input?

A. <keyboard>

B. <input type="keyboard">

C. <key>

D. <kbd>

Answer: D. <kbd>

60. What is the purpose of the HTML attribute placeholder in an input field?

A. It specifies the default value for the input field.

B. It sets the font style for the input field.

C. It defines the size of the input field.

D. It creates a placeholder image in the input field.

Answer: A. It specifies the default value for the input field.

61. What is the purpose of the HTML <iframe> tag?

A. It defines an inline frame.

B. It creates an image frame.

C. It sets the font style for a block of text.

D. It specifies a hyperlink.

Answer: A. It defines an inline frame.

62. Which HTML attribute is used to provide additional information about an element, typically shown
as a tooltip?
A. info

B. title

C. description

D. tooltip

Answer: B. title

63. In HTML, what does the <canvas> element allow you to do?

A. Embed audio files

B. Create 2D and 3D graphics and animations

C. Define custom fonts

D. Specify a document's character set

Answer: B. Create 2D and 3D graphics and animations

64. What is the purpose of the HTML <audio> tag?

A. Creates a navigation link

B. Defines an audio element within the document

C. Sets the background color of a section

D. Specifies a hyperlink

Answer: B. Defines an audio element within the document

65. Which HTML attribute is used to specify the source URL of a video in the <video> tag?

A. video

B. source

C. url

D. src

Answer: D. src
66. In HTML, what does the <details> tag represent?

A. Defines a summary or a legend

B. Creates a new section in the document

C. Sets the font size for a block of text

D. Specifies a hyperlink

Answer: A. Defines a summary or a legend

67. Which HTML tag is used to define a hyperlink that links to an external resource, such as a style sheet
or script?

A. <link>

B. <href>

C. <a>

D. <external>

Answer: A. <link>

68. What is the purpose of the HTML <noscript> tag?

A. Defines a navigation link

B. Specifies a hyperlink

C. Provides alternative content if scripts are not supported

D. Sets the font style for a block of text

Answer: C. Provides alternative content if scripts are not supported

69. In HTML, what does the <map> tag define?

A. A list of navigation links


B. A navigation bar

C. An image map for clickable regions

D. A metadata section

Answer: C. An image map for clickable regions

70. Which HTML tag is used to define a container for an external application or interactive content, such
as a plugin?

A. <embed>

B. <app>

C. <plugin>

D. <container>

Answer: A. <embed>

71. What is the purpose of the HTML <output> tag?

A. It defines an output element for a mathematical calculation.

B. It specifies a navigation link.

C. It creates a new section in the document.

D. It sets the font style for a block of text.

Answer: A. It defines an output element for a mathematical calculation.

72. In HTML, what does the <time> element with the datetime attribute represent?

A. It defines a time zone for the document.

B. It sets the font style for a block of text.

C. It specifies the date and time in a machine-readable format.

D. It creates a countdown timer.

Answer: C. It specifies the date and time in a machine-readable format.


73. Which HTML tag is used to define a progress bar with a specific value?

A. <progress>

B. <meter>

C. <status>

D. <bar>

Answer: B. <meter>

74. What is the purpose of the HTML <mark> element?

A. It defines highlighted or marked text.

B. It sets the font size for a block of text.

C. It creates a navigation link.

D. It specifies a navigation bar.

Answer: A. It defines highlighted or marked text.

75. In HTML, what does the <address> tag represent?

A. It defines an address for the document.

B. It specifies the document title.

C. It creates a block of code.

D. It sets the font color for text.

Answer: A. It defines an address for the document.

76. Which HTML attribute is used to provide alternative text for an image in the <area> tag?

A. alt

B. description
C. text

D. label

Answer: A. alt

77. What is the purpose of the HTML <template> tag?

A. It defines a template section within the document.

B. It creates a new section in the document.

C. It specifies the document title.

D. It sets the font style for a block of text.

Answer: A. It defines a template section within the document.

78. In HTML, what does the <wbr> tag indicate?

A. It defines a line break.

B. It specifies a hyperlink.

C. It represents a word break opportunity.

D. It creates a new section in the document.

Answer: C. It represents a word break opportunity.

79. Which HTML tag is used to define a container for an external resource that should be embedded in a
document?

A. <include>

B. <object>

C. <embed>

D. <external>

Answer: B. <object>
80. What is the purpose of the HTML <sub> tag?

A. It defines a subscript text.

B. It specifies a hyperlink.

C. It creates a new section in the document.

D. It sets the font size for a block of text.

Answer: A. It defines a subscript text.

81. What does the HTML <ruby> tag represent?

A. It defines a ruby annotation for pronunciation.

B. It specifies a navigation link.

C. It creates a new section in the document.

D. It sets the font style for a block of text.

Answer: A. It defines a ruby annotation for pronunciation.

82. In HTML, what does the <samp> tag indicate?

A. It defines sample output from a computer program.

B. It specifies the document title.

C. It creates a block of code.

D. It sets the font color for text.

Answer: A. It defines sample output from a computer program.

83. Which HTML tag is used to define a keyboard input in a form?

A. <input type="keyboard">

B. <kbd>

C. <key>
D. <keyboard>

Answer: B. <kbd>

84. What is the purpose of the HTML <small> tag?

A. It defines small text.

B. It specifies a hyperlink.

C. It creates a new section in the document.

D. It sets the font size for a block of text.

Answer: A. It defines small text.

85. In HTML, what does the <cite> tag represent?

A. It specifies a citation or reference.

B. It creates a new section in the document.

C. It sets the font style for a block of text.

D. It defines a navigation link.

Answer: A. It specifies a citation or reference.

86. Which HTML attribute is used to specify the language of the content inside the <script> tag?

A. type

B. lang

C. language

D. src

Answer: B. lang

87. What is the purpose of the HTML <abbr> tag?


A. It defines an abbreviation or acronym.

B. It sets the font color for a block of text.

C. It creates a new section in the document.

D. It specifies a navigation link.

Answer: A. It defines an abbreviation or acronym.

88. In HTML, what does the <blockquote> tag represent?

A. It defines a block of code.

B. It creates a block-level division.

C. It defines a block of text as a quotation.

D. It sets the font size for a block of text.

Answer: C. It defines a block of text as a quotation.

89. Which HTML tag is used to define the text direction of the content within it?

A. <direction>

B. <rtl>

C. <textdir>

D. <bidi>

Answer: B. <rtl>

90. What is the purpose of the HTML <hr> tag?

A. It creates a hyperlink.

B. It defines a horizontal rule.

C. It specifies a navigation link.

D. It sets the font style for a block of text.

Answer: B. It defines a horizontal rule.


91. What does the HTML <s> tag represent?

A. It defines a section in the document.

B. It creates a strikethrough effect for text.

C. It specifies a navigation link.

D. It sets the font size for a block of text.

Answer: B. It creates a strikethrough effect for text.

92. In HTML, what is the purpose of the <figure> and <figcaption> elements when used together?

A. They create a new section in the document.

B. They define a figure or an image.

C. They specify a caption for an image.

D. They set the font style for a block of text.

Answer: C. They specify a caption for an image.

93. Which HTML tag is used to define the base URL for all relative URLs within a document?

A. <url>

B. <base>

C. <root>

D. <home>

Answer: B. <base>

94. What is the purpose of the HTML attribute role?

A. It defines the role of a script in the document.

B. It specifies the role of a form element.


C. It sets the font style for a block of text.

D. It defines the accessibility role of an element.

Answer: D. It defines the accessibility role of an element.

95. In HTML, what does the <nav> element typically represent?

A. It defines a navigation link.

B. It creates a new section in the document.

C. It specifies a navigation bar.

D. It sets the font size for a block of text.

Answer: C. It specifies a navigation bar.

96. Which HTML tag is used to define an ordered list item within a nested list?

A. <nl>

B. <li>

C. <ol>

D. <listitem>

Answer: B. <li>

97. What is the purpose of the HTML <track> tag?

A. It defines a track for audio or video content.

B. It sets the background color of a section.

C. It creates a new section in the document.

D. It specifies a hyperlink.

Answer: A. It defines a track for audio or video content.

98. In HTML, what does the <ins> tag represent?


A. It defines an inline style for text.

B. It specifies a navigation link.

C. It creates a block of code.

D. It represents inserted text.

Answer: D. It represents inserted text.

99. Which HTML tag is used to define a container for navigation links in a navigation bar?

A. <navbar>

B. <navlink>

C. <nav>

D. <linkbar>

Answer: C. <nav>

100. What is the purpose of the HTML attribute controls in the <audio> and <video> tags?

A. It sets the font style for the media content.

B. It specifies a navigation link.

C. It provides user controls for the media player.

D. It defines the audio or video source URL.

Answer: C. It provides user controls for the media player.

101. Which HTML tag is used to define a section that contains metadata about the document, such as
the title and character set?

A. <meta>

B. <head>

C. <title>
D. <metadata>

Answer: B. <head>

102. In HTML, what does the <meta charset="UTF-8"> tag define?

A. It sets the font style for text.

B. It specifies the character encoding for the document.

C. It creates a new section in the document.

D. It defines a metadata element.

Answer: B. It specifies the character encoding for the document.

103. What is the purpose of the HTML attribute async in the <script> tag?

A. It sets the font style for the script.

B. It specifies that the script should be executed asynchronously.

C. It defines an alternative script if the primary one fails.

D. It creates a new section in the document.

Answer: B. It specifies that the script should be executed asynchronously.

104. Which HTML tag is used to define a hyperlink that links to an external style sheet?

A. <link>

B. <style>

C. <a>

D. <href>

Answer: A. <link>

105. In HTML, what does the <style> tag define?


A. It specifies a navigation link.

B. It defines a style block containing CSS rules for the document.

C. It sets the font size for a block of text.

D. It creates a new section in the document.

Answer: B. It defines a style block containing CSS rules for the document.

106. What is the purpose of the HTML <noscript> tag?

A. It defines a navigation link.

B. It provides alternative content if scripts are not supported.

C. It creates a new section in the document.

D. It sets the font style for a block of text.

Answer: B. It provides alternative content if scripts are not supported.

107. Which HTML attribute is used to specify the media type of the linked resource in the <link> tag?

A. type

B. media

C. format

D. src

Answer: A. type

108. In HTML, what does the <base> tag define?

A. It sets the font style for text.

B. It defines the base URL for all relative URLs within a document.

C. It specifies a navigation link.

D. It creates a new section in the document.

Answer: B. It defines the base URL for all relative URLs within a document.
109. What is the purpose of the HTML attribute defer in the <script> tag?

A. It sets the font style for the script.

B. It specifies that the script should be executed after the document is parsed.

C. It defines an alternative script if the primary one fails.

D. It creates a new section in the document.

Answer: B. It specifies that the script should be executed after the document is parsed.

110. Which HTML tag is used to define a container for the main content of a document, excluding
headers, footers, and sidebars?

A. <container>

B. <body>

C. <main>

D. <content>

Answer: C. <main>

111. In HTML, what does the <iframe> tag allow you to do?

A. Embed audio files

B. Create a container for external content

C. Create an inline frame for external content

D. Define a figure or an image

Answer: C. Create an inline frame for external content

112. What is the purpose of the HTML <figcaption> tag?

A. Define a figure or an image


B. Create a caption for a figure

C. Set the font style for a block of text

D. Specify a hyperlink

Answer: B. Create a caption for a figure

113. Which HTML tag is used to define a semantic break in an HTML document, indicating a thematic
change in content?

A. <div>

B. <section>

C. <aside>

D. <hr>

Answer: B. <section>

114. In HTML, what is the purpose of the <details> and <summary> elements when used together?

A. Create a dropdown menu

B. Define a summary or legend for an element

C. Create an accordion-style interactive widget

D. Specify a navigation link

Answer: C. Create an accordion-style interactive widget

115. What does the HTML <meter> tag represent?

A. Defines a progress bar

B. Creates a container for external content

C. Specifies a list of options for an input element

D. Represents a scalar measurement within a known range

Answer: D. Represents a scalar measurement within a known range


116. Which HTML tag is used to define a container for navigation links within a navigation bar?

A. <nav>

B. <navbar>

C. <linkbar>

D. <ul>

Answer: A. <nav>

117. In HTML, what does the <wbr> tag indicate?

A. Defines a word break opportunity

B. Specifies a hyperlink

C. Represents a line break

D. Creates a new section in the document

Answer: A. Defines a word break opportunity

118. What is the purpose of the HTML <rp> tag?

A. Defines a ruby parenthesis for pronunciation

B. Sets the font style for a block of text

C. Specifies a navigation link

D. Creates a responsive layout

Answer: A. Defines a ruby parenthesis for pronunciation

119. Which HTML attribute is used to specify the language of the content within the <html> tag?

A. lang

B. language
C. html-lang

D. xml:lang

Answer: A. lang

120. What is the purpose of the HTML <bdi> tag?

A. Sets the font weight to bold

B. Defines a bi-directional isolation for text

C. Creates a block of code

D. Specifies a navigation link

Answer: B. Defines a bi-directional isolation for text

UNIT 2 MCQ

Question 1: What does HTML stand for?

A) HyperText Markup Language

B) High-Level Text Management Language

C) Hyper Transferable Markup Language

D) Hyperlink and Text Manipulation Language

Answer: A) HyperText Markup Language

Question 2: 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
Question 3: What keyword is used to declare a variable in JavaScript?

A) variable

B) v

C) var

D) declare

Answer: C) var

Question 4: Which HTML tag is used to create a text input field in a form?

A) <input>

B) <text>

C) <textfield>

D) <form-text>

Answer: A) <input>

Question 5: In the CSS box model, which property defines the space between an element's border and
its content?

A) margin

B) padding

C) border-space

D) spacing

Answer: B) padding

Question 6: What is the purpose of the return statement in a JavaScript function?

A) To exit the function

B) To display a message

C) To return a value from the function

D) To declare a variable

Answer: C) To return a value from the function


Question 7: What is the CSS property used to make a webpage responsive by adjusting the layout based
on the device's screen size?

A) layout-mode

B) responsive-layout

C) media-query

D) screen-size

Answer: C) media-query

Question 8: How can you access the value of a property named "age" in a JavaScript object called
person?

A) person.age

B) person["age"]

C) person->age

D) person@age

Answer: B) person["age"]

Question 9: Which HTML5 element is used to define the main content of a document?

A) <main>

B) <content>

C) <body>

D) <section>

Answer: A) <main>

Question 10: What CSS property is used to create a flexible container with equal-width columns?

A) float

B) grid

C) flex

D) column-width
Answer: C) flex

Question 11: What HTML tag is used to create a dropdown list in a form?

A) <select>

B) <dropdown>

C) <list>

D) <input type="dropdown">

Answer: A) <select>

Question 12: Which CSS selector selects all elements of a specific type?

A) *

B) .class

C) #id

D) element

Answer: D) element

13. JavaScript Events:

Question 13: Which event is triggered when a user clicks on an HTML element?

A) mouseover

B) onhover

C) onclick

D) onselect

Answer: C) onclick

Question 14: What HTML tag is used to define a table row?

A) <td>

B) <th>

C) <tr>
D) <table-row>

Answer: C) <tr>

Question 15: Which CSS property is used to control the stacking order of elements?

A) layer

B) z-index

C) stack-order

D) order

Answer: B) z-index

Question 16: How do you add a new element to the end of an array in JavaScript?

A) array.add()

B) array.push()

C) array.insert()

D) array.append()

Answer: B) array.push()

Question 17: What CSS property is used to set the width of an element?

A) size

B) width

C) length

D) dimension

Answer: B) width

Question 18: How can you change the text content of an HTML element with the id "myElement" using
JavaScript?

A) document.getElement("myElement").textContent = "New Text";

B) document.getElementById("myElement").innerHTML = "New Text";

C) document.getElementByName("myElement").value = "New Text";


D) document.querySelector("myElement").innerText = "New Text";

Answer: B) document.getElementById("myElement").innerHTML = "New Text";

Question 19: What is the purpose of the viewport meta tag in HTML?

A) To set the background color of the webpage

B) To define the initial scale of the webpage

C) To specify the font size of the webpage

D) To hide the address bar of the browser

Answer: B) To define the initial scale of the webpage

Question 20: Which CSS property is used to align items vertically in a flex container?

A) justify-content

B) align-items

C) flex-align

D) flex-vertical

Answer: B) align-items

Question 21: What is the purpose of the catch method in a JavaScript promise?

A) To reject a promise

B) To resolve a promise

C) To handle errors in a promise

D) To chain multiple promises

Answer: C) To handle errors in a promise

Question 22: Which HTML tag is used to set the character encoding for the document?

A) <encoding>

B) <charset>

C) <meta charset="UTF-8">

D) <head>
Answer: C) <meta charset="UTF-8">

Question 23: In CSS, which pseudo-class selects the first child element of its parent?

A) :first-child

B) :first-of-type

C) :child

D) :nth-child(1)

Answer: A) :first-child

Question 24: What is the scope of a variable declared with the let keyword in JavaScript?

A) Global scope

B) Local scope

C) Block scope

D) Function scope

Answer: C) Block scope

Question 25: Which CSS property is used to specify the duration of a transition effect?

A) transition-timing

B) animation-duration

C) transition-duration

D) timing-function

Answer: C) transition-duration

Question 26: How do you access the value of a nested property in a JavaScript object?

A) object.getProperty("nestedProperty")

B) object[nestedProperty]

C) object.get("nestedProperty")

D) object.property("nestedProperty")

Answer: B) object[nestedProperty]
Question 27: Which HTML tag is used to embed an audio file?

A) <sound>

B) <audio>

C) <music>

D) <media>

Answer: B) <audio>

Question 28: In CSS Grid, which property is used to define the size of columns and rows?

A) grid-size

B) column-row-size

C) grid-template-columns / grid-template-rows

D) size

Answer: C) grid-template-columns / grid-template-rows

Question 29: What is the purpose of the let keyword in JavaScript ES6?

A) To declare a constant variable

B) To declare a block-scoped variable

C) To declare a global variable

D) To declare a variable with function scope

Answer: B) To declare a block-scoped variable

Question 30: Which HTML5 element is used to define navigation links?

A) <nav>

B) <navigate>

C) <links>

D) <navigation>

Answer: A) <nav>
Question 31: Which CSS property is used to specify the name of the animation?

A) animation-name

B) animate

C) animation

D) name

Answer: A) animation-name

Question 32: How do you parse a JSON string into a JavaScript object?

A) parseJSON()

B) JSON.parse()

C) stringifyJSON()

D) JSON.stringify()

Answer: B) JSON.parse()

Question 33: What is the purpose of the HTML <head> element?

A) To define the main content of the document

B) To set the background color of the document

C) To provide metadata about the document

D) To create a section within the document

Answer: C) To provide metadata about the document

Question 34: In CSS, which selector has the highest specificity?

A) Class selector (e.g., .example)

B) ID selector (e.g., #uniqueElement)

C) Universal selector (e.g., *)

D) Type selector (e.g., p)

Answer: B) ID selector (e.g., #uniqueElement)

Question 35: What is the purpose of the arguments object in a JavaScript function?
A) To store the function's return value

B) To represent the function's parameters as an array

C) To access the function's local variables

D) To declare global variables within the function

Answer: B) To represent the function's parameters as an array

Question 36: Which HTML5 element is used to define the footer of a document or section?

A) <footer>

B) <bottom>

C) <end>

D) <section-footer>

Answer: A) <footer>

Question 37: What CSS property is used to align items horizontally in a flex container?

A) justify-content

B) align-items

C) flex-align

D) flex-horizontal

Answer: A) justify-content

Question 38: What is a callback function in JavaScript?

A) A function that is executed immediately when it is defined

B) A function that is passed as an argument to another function and executed later

C) A function that is used to handle errors in asynchronous code

D) A function that returns another function

Answer: B) A function that is passed as an argument to another function and executed later

Question 39: Which HTML tag is used to embed a video file?

A) <movie>
B) <video>

C) <media>

D) <film>

Answer: B) <video>

Question 40: Which CSS property is used to scale an element in both the horizontal and vertical
directions?

A) scale

B) transform-scale

C) transform

D) resize

Answer: C) transform

Question 41: What is a closure in JavaScript?

A) A function that is declared within another function

B) A variable declared with the let keyword

C) A way to encapsulate variables within a function and access them later

D) A function that returns another function

Answer: C) A way to encapsulate variables within a function and access them later

Question 42: Which HTML input type is used for a checkbox?

A) <input type="check">

B) <input type="checkbox">

C) <checkbox>

D) <check>

Answer: B) <input type="checkbox">

Question 43: Which CSS property is used to control what happens to content that is too big to fit into an
area?
A) overflow-mode

B) content-overflow

C) overflow

D) text-overflow

Answer: C) overflow

Question 44: What does the this keyword refer to in JavaScript?

A) It always refers to the global object

B) It refers to the object the method was called on

C) It refers to the object where it is defined

D) It refers to the parent function

Answer: B) It refers to the object the method was called on

Question 45: Which CSS value for the position property removes an element from the normal document
flow?

A) static

B) relative

C) fixed

D) absolute

Answer: C) fixed

Question 46: What is the purpose of the async keyword in JavaScript?

A) To declare a function as asynchronous

B) To define an anonymous function

C) To pause the execution of a function

D) To handle errors in a function

Answer: A) To declare a function as asynchronous

Question 47: What is the purpose of the HTML <meta> tag with the viewport attribute?
A) To set the background color of the document

B) To define the initial scale of the document

C) To hide the address bar of the browser

D) To provide metadata about the document

Answer: B) To define the initial scale of the document

Question 48: In CSS, which pseudo-element selects the first line of an element?

A) :first-line

B) :line-first

C) ::first-line

D) ::line-first

Answer: C) ::first-line

Question 49: How do you store data in the localStorage object in JavaScript?

A) localStorage.storeData("key", "value");

B) localStorage.setItem("key", "value");

C) localStorage.data("key", "value");

D) localStorage.save("key", "value");

Answer: B) localStorage.setItem("key", "value");

Question 50: What is the purpose of the HTML <article> element?

A) To define a section within the document

B) To define the main content of the document

C) To represent a self-contained piece of content

D) To create an article within the document

Answer: C) To represent a self-contained piece of content

Question 51: Which CSS property is used to create a linear gradient background?

A) background-color
B) gradient-color

C) background-image

D) linear-gradient

Answer: C) `

Question 52: What keyword is used to handle errors in a JavaScript try...catch block?

A) handle

B) catch

C) error

D) exception

Answer: B) catch

Question 53: Which HTML5 element is used to define the header of a document or section?

A) <header>

B) <head>

C) <top>

D) <document-header>

Answer: A) <header>

Question 54: Which CSS property is used to rotate an element?

A) rotate

B) transform-rotate

C) rotate-transform

D) transform

Answer: D) transform

Question 55: What does the map function do in JavaScript?

A) Creates a new array by applying a function to each element of an existing array

B) Removes elements from an array


C) Concatenates two arrays

D) Filters elements in an array based on a condition

Answer: A) Creates a new array by applying a function to each element of an existing array

Question 56: What does the CSS box-sizing: border-box; property do?

A) Includes the padding and border in the element's total width and height

B) Excludes the padding and border from the element's total width and height

C) Only includes the padding in the element's total width and height

D) Only includes the border in the element's total width and height

Answer: A) Includes the padding and border in the element's total width and height

Question 57: How do you select an element with the id "example" using JavaScript querySelector?

A) querySelector("#example")

B) querySelector(".example")

C) querySelector("example")

D) getElementById("example")

Answer: A) querySelector("#example")

Question 58: Which HTML attribute is used to provide a text alternative for images for accessibility?

A) alt

B) description

C) text-alt

D) image-description

Answer: A) alt

Question 59: What is the default value of the CSS position property?

A) relative

B) fixed

C) absolute
D) static

Answer: D) static

Question 60: What is the purpose of the JavaScript Set object?

A) To store values of the same type

B) To store unique values of any type

C) To store key-value pairs

D) To store only numbers

Answer: B) To store unique values of any type

Question 61: Which HTML attribute is used to specify the source of an embedded audio or video file?

A) source

B) media

C) src

D) file

Answer: C) src

Question 62: What does the CSS flex-direction property control in a flex container?

A) The spacing between flex items

B) The order of flex items

C) The direction of the main axis

D) The direction of the cross axis

Answer: C) The direction of the main axis

Question 63: How do you set a timeout for a function to execute after 3 seconds in JavaScript?

A) setInterval(myFunction, 3000);

B) timeout(myFunction, 3000);

C) setTimeout(myFunction, 3000);

D) delay(myFunction, 3000);
Answer: C) setTimeout(myFunction, 3000);

Question 64: Which HTML5 element is used to define the main content of an article?

A) <content>

B) <main>

C) <article-main>

D) <article-content>

Answer: B) <main>

Question 65: What is the range of values for the CSS opacity property?

A) 0 to 100

B) 0 to 1

C) 1 to 100

D) -1 to 1

Answer: B) 0 to 1

Question 66: What does the JavaScript splice method do?

A) Adds elements to the beginning of an array

B) Removes elements from an array and returns the removed elements

C) Concatenates two arrays

D) Sorts the elements of an array

Answer: B) Removes elements from an array and returns the removed elements

Question 67: What HTML5 element is used to draw graphics on a web page?

A) <drawing>

B) <graphics>

C) <canvas>

D) <paint>

Answer: C) <canvas>
Question 68: What does the CSS line-height property control?

A) The spacing between lines of text

B) The height of an element

C) The thickness of a line

D) The height of a paragraph

Answer: A) The spacing between lines of text

Question 69: What does the JavaScript filter method do?

A) Creates a new array with the results of calling a provided function on every element in the array

B) Removes elements from an array based on a condition

C) Sorts the elements of an array

D) Adds elements to the beginning of an array

Answer: B) Removes elements from an array based on a condition

Question 70: Which attribute is used in HTML to provide a short hint describing the content of an input
field?

A) placeholder

B) hint

C) tooltip

D) description

Answer: A) placeholder

Question 71: How do you set a background image for an element in CSS?

A) background: url("image.jpg");

B) background-img: url("image.jpg");

C) background-image: url("image.jpg");

D) img: url("image.jpg");

Answer: C) background-image: url("image.jpg");


Question 72: What does the JavaScript reduce method do?

A) Adds all elements of an array into a single value

B) Removes the first element from an array

C) Sorts the elements of an array

D) Creates a new array with the results of calling a provided function on every element

Answer: A) Adds all elements of an array into a single value

Question 73: In HTML, which element is used to define content aside from the content it is placed in?

A) <sidebar>

B) <note>

C) <aside>

D) <section>

Answer: C) <aside>

Question 74: Which CSS property is used to specify the name of the property you want to transition?

A) transition

B) property

C) transition-property

D) animate

Answer: C) transition-property

Question 75: In JavaScript, how do you get the character at a specified index in a string?

A) string.indexChar(2);

B) string.charAt(2);

C) string.charAtIndex(2);

D) string[2];

Answer: B) string.charAt(2);
Question 76: Which HTML5 element is used to create a disclosure widget from which the user can
obtain additional information or controls?

A) <disclose>

B) <expand>

C) <details>

D) <more-info>

Answer: C) <details>

Question 77: What does the CSS box-shadow property control?

A) The shadow of the content area

B) The shadow of the margin area

C) The shadow of the border area

D) The shadow of the padding area

Answer: C) The shadow of the border area

Question 78: What is the key difference between localStorage and sessionStorage in JavaScript?

A) localStorage has a longer storage duration than sessionStorage

B) sessionStorage can store larger amounts of data than localStorage

C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a single tab

D) sessionStorage is only available in modern browsers

Answer: C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a
single tab

Question 79: In HTML, which element is used to define a set of navigation links?

A) <navigate>

B) <links>

C) <navigation>
D) <nav>

Answer: D) <nav>

Question 80: What is the difference between display: none; and visibility: hidden; in CSS?

A) Both properties hide the element, but visibility: hidden; still occupies space

B) visibility: hidden; hides the element and removes it from the document flow

C) display: none; hides the element but still occupies space

D) There is no difference between them; they achieve the same result

Answer: A) Both properties hide the element, but visibility: hidden; still occupies space

Question 81: In JavaScript, what does the typeof operator return for the data type of a variable?

A) The name of the variable

B) The memory address of the variable

C) The size of the variable

D) A string representing the data type of the variable

Answer: D) A string representing the data type of the variable

Question 82: In HTML, which element is used to represent a specific period in time, typically with a
machine-readable format?

A) <datetime>

B) <timestamp>

C) <date>

D) <time>

Answer: D) <time>

Question 83: What is the default value of the CSS box-sizing property?

A) content-box

B) border-box

C) padding-box
D) margin-box

Answer: A) content-box

Question 84: What is the purpose of the second parameter in the JavaScript splice method?

A) To specify the index where elements should be added

B) To specify the number of elements to be removed

C) To specify the element to be added

D) To specify the index where elements should be removed

Answer: B) To specify the number of elements to be removed

Question 85: In HTML, which element is used to represent the progress of a task?

A) <loading>

B) <progress-bar>

C) <progress>

D) <task-progress>

Answer: C) <progress>

Question 86: What does the CSS flex-wrap property control in a flex container?

A) The alignment of flex items

B) The order of flex items

C) The wrapping of flex items when they exceed the container width

D) The spacing between flex items

Answer: C) The wrapping of flex items when they exceed the container width

Question 87: What does the JavaScript isNaN function return?

A) true if the value is not a number, otherwise false

B) false if the value is not a number, otherwise true

C) undefined if the value is not a number

D) The value itself if it is a number, otherwise null


Answer: A) true if the value is not a number, otherwise false

Question 88: What content is typically placed inside an HTML <article> element?

A) Navigation links

B) Metadata about the document

C) Self-contained content that can be distributed and reused independently

D) Styling information for the document

Answer: C) Self-contained content that can be distributed and reused independently

Question 89: What does the CSS property position: fixed; do?

A) Positions the element relative to its normal position in the document flow

B) Positions the element relative to its closest positioned ancestor

C) Positions the element relative to the viewport, so it stays fixed while scrolling

D) Fixes the element's size to a specific width and height

Answer: C) Positions the element relative to the viewport, so it stays fixed while scrolling

Question 90: What does the JavaScript forEach method do?

A) Adds elements to the end of an array

B) Removes elements from an array

C) Calls a provided function once for each element in the array, in order

D) Creates a new array with the results of calling a provided function on every element

Answer: C) Calls a provided function once for each element in the array, in order

Question 91: What is the purpose of the HTML5 <figure> and <figcaption> elements?

A) To create a container for an image

B) To represent a standalone piece of content, such as an image or a video, with an optional caption

C) To define a section within the document

D) To create a caption for an image within a paragraph


Answer: B) To represent a standalone piece of content, such as an image or a video, with an optional
caption

Question 92: What effect does the CSS property overflow: hidden; have on an element?

A) Expands the element to fit its content

B) Hides any content that overflows the element's box

C) Adds a hidden scrollbar to the element

D) Centers the content within the element

Answer: B) Hides any content that overflows the element's box

Question 93: How do you get the current date and time in JavaScript?

A) getCurrentDate()

B) new Date()

C) getCurrentTime()

D) getCurrentDateTime()

Answer: B) new Date()

Question 94: In HTML5, what is the purpose of the <mark> element?

A) To highlight text as important or relevant

B) To create a clickable link

C) To define a section within the document

D) To mark the end of a document

Answer: A) To highlight text as important or relevant

Question 95: What does the CSS property flex-grow control in a flex container?

A) The size of the flex items

B) The order of the flex items

C) The spacing between flex items


D) The ability of flex items to grow relative to each other

Answer: D) The ability of flex items to grow relative to each other

Question 96: What is the maximum storage capacity of the localStorage object in most browsers?

A) 5 MB

B) 10 MB

C) 2.5 MB

D) 1 MB

Answer: B) 10 MB

Question 97: In HTML, what is the purpose of the <abbr> element?

A) To create an abbreviation for a word or phrase

B) To define a block of code

C) To represent a table row

D) To create a clickable link

Answer: A) To create an abbreviation for a word or phrase

Question 98: What does the CSS property text-transform do?

A) Changes the font size of the text

B) Transforms the text to uppercase, lowercase, or capitalize

C) Adds shadows to the text

D) Applies a background color to the text

Answer: B) Transforms the text to uppercase, lowercase, or capitalize

Question 99: How do you generate a random decimal number between 0 (inclusive) and 1 (exclusive) in
JavaScript using Math.random()?

A) Math.random(0, 1);

B) random.decimal(0, 1);

C) Math.random() * 1;
D) Math.randomDecimal();

Answer: C) Math.random() * 1;

Question 100: In HTML, what is the purpose of the <cite> element?

A) To create a citation for a block of text

B) To define a code citation

C) To represent a table cell

D) To mark the end of a document

Answer: A) To create a citation for a block of text

Question 101: What does the CSS z-index property control?

A) The font size of the text

B) The spacing between elements

C) The stacking order of elements along the z-axis

D) The transparency of elements

Answer: C) The stacking order of elements along the z-axis

Question 102: In JavaScript, what does the Object.keys() method return?

A) The values of an object

B) The keys of an object as an array

C) The length of an object

D) The prototype of an object

Answer: B) The keys of an object as an array

Question 103: In HTML, what is the purpose of the <address> element?

A) To define a section within the document

B) To create a clickable link

C) To represent a block of code


D) To provide contact information for the nearest ancestor or article

Answer: D) To provide contact information for the nearest ancestor or article

Question 104: In the CSS box-shadow property, what does the first length value represent?

A) The blur radius

B) The spread radius

C) The horizontal offset

D) The vertical offset

Answer: C) The horizontal offset

Question 105: How do you check if a variable is an array in JavaScript?

A) isArray(variable);

B) isTypeOf(variable, "array");

C) variable.isType("array");

D) Array.isArray(variable);

Answer: D) Array.isArray(variable);

Question 106: In HTML5, what is the purpose of the <datalist> element?

A) To create a list of data elements

B) To define a navigation menu

C) To associate a list of predefined options with an input element

D) To represent a time value

Answer: C) To associate a list of predefined options with an input element

Question 107: What does the CSS text-decoration property control?

A) The font style of the text

B) The color of the text

C) The spacing between letters

D) The decoration of the text (underline, overline, line-through, etc.)


Answer: D) The decoration of the text (underline, overline, line-through, etc.)

Question 108: In JavaScript, what is the purpose of the JSON.stringify() method?

A) Parses a JSON string into a JavaScript object

B) Converts a JavaScript object or value to a JSON string

C) Stringifies a regular JavaScript string

D) Returns a JSON object

Answer: B) Converts a JavaScript object or value to a JSON string

Question 109: In HTML, what is the purpose of the <kbd> element?

A) To define a keyboard input

B) To represent a table row

C) To create a clickable link

D) To mark the end of a document

Answer: A) To define a keyboard input

Question 110: What does the CSS property position: relative; do?

A) Positions the element relative to its normal position in the document flow

B) Positions the element relative to its closest positioned ancestor

C) Positions the element relative to the viewport, so it stays fixed while scrolling

D) Centers the element within its containing element

Answer: A) Positions the element relative to its normal position in the document flow

Question 111: What are the two phases of event propagation in the DOM?

A) Capture and Bubble

B) Start and Finish

C) Up and Down

D) In and Out
Answer: A) Capture and Bubble

Question 112: In HTML, what is the purpose of the <iframe> element?

A) To create an inline frame for embedding external content

B) To define a block of code

C) To represent a table cell

D) To create an interactive form

Answer: A) To create an inline frame for embedding external content

Question 113: What is the difference between box-sizing: content-box; and box-sizing: border-box;?

A) content-box includes padding and border in the total width and height, while border-box includes
only content

B) content-box includes padding in the total width and height, while border-box includes padding and
border

C) There is no difference between them; they produce the same result

D) content-box and border-box are not valid values for the box-sizing property

Answer: B) content-box includes padding in the total width and height, while border-box includes
padding and border

Question 114: What does the JavaScript fetch function return?

A) The response body as a JSON object

B) A Promise that resolves to the Response object representing the completion of the request

C) The request URL

D) An array of data fetched from the server

Answer: B) A Promise that resolves to the Response object representing the completion of the request

Question 115: Which attribute is used in HTML to provide an accessible name for an element?

A) title
B) aria-label

C) alt

D) role

Answer: B) aria-label

Question 116: What does the CSS property display: flex; do?

A) Turns the element into a block-level container with a flex container inside

B) Turns the element into an inline-level container with a flex container inside

C) Turns the element into a flex container, making it a block-level container

D) Turns the element into a flex item inside a flex container

Answer: C) Turns the element into a flex container, making it a block-level container

Question 117: What is a key difference between localStorage and sessionStorage?

A) localStorage has a longer storage duration than sessionStorage

B) sessionStorage can store larger amounts of data than localStorage

C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a single tab

D) sessionStorage persists data even after the browser is closed, while localStorage does not

Answer: C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a
single tab

Question 118: Which HTML5 element is used to define the header of a document or section?

A) <header>

B) <head>

C) <top>

D) <document-header>

Answer: A) <header>

Question 119: What is the positioning reference for an element with position: absolute;?

A) The viewport
B) The nearest positioned ancestor

C) The document flow

D) The nearest block-level ancestor

Answer: B) The nearest positioned ancestor

Question 120: What are the three states of a Promise in JavaScript?

A) Pending, Resolved, Rejected

B) Initiated, Processing, Completed

C) Started, Finished, Failed

D) Waiting, Fulfilled, Broken

Answer: A) Pending, Resolved, Rejected

UNIT 3 MCQ

HTML stands for:

a. HyperText Markup Language

b. High-level Text Management Language

c. Hyper Transfer Markup Language

d. HyperText Manipulation Language

Answer: a. HyperText Markup Language

Which tag is used to link an external CSS file in HTML?

a. <link>

b. <style>

c. <css>

d. <external>

Answer: a. <link>
What does CSS stand for?

a. Counter Style Sheet

b. Computer Style Sheet

c. Cascading Style Sheet

d. Creative Style Sheet

Answer: c. Cascading Style Sheet

Which CSS property is used to change the text color of an element?

a. text-color

b. font-color

c. color

d. text-style

Answer: c. color

In CSS, how do you select an element with id "header"?

a. #header

b. .header

c. header

d. element-header

Answer: a. #header

Which HTML tag is used to create an ordered list?

a. <ol>

b. <ul>

c. <li>

d. <list>

Answer: a. <ol>
What is the purpose of the CSS margin property?

a. Adds space inside the border of an element

b. Adds space outside the border of an element

c. Changes the border color

d. Changes the element's width

Answer: b. Adds space outside the border of an element

What does the acronym URL stand for?

a. Universal Resource Locator

b. Uniform Resource Locator

c. Unified Resource Locator

d. Universal Routing Locator

Answer: b. Uniform Resource Locator

Which HTML tag is used for creating hyperlinks?

a. <link>

b. <a>

c. <href>

d. <hyperlink>

Answer: b. <a>

In CSS, the float property is used for:

a. Text alignment

b. Image positioning

c. Background color

d. Font styling

Answer: b. Image positioning

Which of the following is the correct way to comment out multiple lines 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 -->

What is the purpose of the HTML <meta> tag?

a. Define metadata about an HTML document

b. Create a hyperlink

c. Define a new paragraph

d. Embed external scripts

Answer: a. Define metadata about an HTML document

Which of the following CSS selectors selects all elements of a specific type?

a. #element

b. .element

c. element

d. element

Answer: d. element

What is the purpose of the CSS padding property?

a. Adds space inside the border of an element

b. Adds space outside the border of an element

c. Changes the element's background color

d. Changes the element's font size

Answer: a. Adds space inside the border of an element

In HTML, which tag is used to create a hyperlink to an email address?

a. <mail>
b. <email>

c. <a href="mailto:...">

d. <link to="email:...">

Answer: c. <a href="mailto:...">

What does the CSS property position: relative; do?

a. Positions an element relative to its normal position

b. Sets the relative size of the font

c. Aligns text to the right

d. Sets the background color

Answer: a. Positions an element relative to its normal position

Which HTML tag is used to define the structure of an HTML document, including the title and meta
information?

a. <head>

b. <body>

c. <html>

d. <meta>

Answer: c. <html>

In CSS, what property is used to control the space between lines of text within an element?

a. line-spacing

b. text-spacing

c. line-height

d. text-height

Answer: c. line-height

What is the purpose of the CSS border-radius property?

a. Changes the color of the border


b. Adds a shadow to the border

c. Rounds the corners of an element's border

d. Adjusts the thickness of the border

Answer: c. Rounds the corners of an element's border

Which of the following is the correct way to apply an external CSS file to an HTML document using the
<link> tag?

a. <link src="style.css" type="text/css">

b. <link rel="stylesheet" type="text/css" href="style.css">

c. <style src="style.css" type="text/css">

d. <style rel="stylesheet" type="text/css" href="style.css">

Answer: b. <link rel="stylesheet" type="text/css" href="style.css">

What does the acronym CSS stand for?

a. Counter Style Sheet

b. Computer Style Sheet

c. Cascading Style Sheet

d. Creative Style Sheet

Answer: c. Cascading Style Sheet

Which HTML tag is used for creating an unordered list?

a. <ol>

b. <ul>

c. <li>

d. <list>

Answer: b. <ul>

In CSS, what property is used to set the background color of an element?

a. background-color
b. color

c. bgcolor

d. background

Answer: a. background-color

What is the purpose of the HTML <head> tag?

a. Contains the main content of the HTML document

b. Defines the structure of the document

c. Contains metadata about the HTML document

d. Specifies the footer of the document

Answer: c. Contains metadata about the HTML document

Which CSS property is used for controlling the space between elements in a layout?

a. margin

b. padding

c. spacing

d. border-spacing

Answer: a. margin

In HTML, what does the <br> tag do?

a. Creates a break in the page and moves to the next line

b. Defines a bold text

c. Creates a bullet point

d. Adds a background color

Answer: a. Creates a break in the page and moves to the next line

Which of the following is the correct way to include an external JavaScript file in an HTML document?

a. <script type="text/javascript" src="script.js"></script>

b. <link rel="javascript" href="script.js">


c. <js src="script.js"></js>

d. <include script="script.js">

Answer: a. <script type="text/javascript" src="script.js"></script>

What is the purpose of the CSS display property?

a. Controls the visibility of an element

b. Sets the display mode of an element

c. Adjusts the width of an element

d. Changes the font size

Answer: b. Sets the display mode of an element

Which HTML tag is used for creating a hyperlink to another webpage?

a. <link>

b. <a>

c. <href>

d. <hyperlink>

Answer: b. <a>

In CSS, the position: absolute; property is positioned relative to:

a. Its normal position

b. The nearest positioned ancestor

c. The window

d. The document body

Answer: c. The window

What is the purpose of the HTML <meta> tag with the charset attribute?

a. Specifies the character set encoding for the HTML document

b. Defines metadata about the document

c. Sets the background color


d. Links to an external stylesheet

Answer: a. Specifies the character set encoding for the HTML document

In CSS, the z-index property is used for:

a. Changing the font size

b. Adjusting the order of stacked elements

c. Setting the width of an element

d. Controlling the space between lines of text

Answer: b. Adjusting the order of stacked elements

Which CSS property is used for changing the style of the cursor when it hovers over an element?

a. cursor-style

b. hover-cursor

c. mouse-cursor

d. cursor

Answer: d. cursor

What is the purpose of the HTML <footer> tag?

a. Contains the main content of the HTML document

b. Defines a footer for the document

c. Contains metadata about the HTML document

d. Specifies a hyperlink

Answer: b. Defines a footer for the document

In CSS, what is the purpose of the @media rule?

a. Defines media files to be used in the document

b. Applies styles based on the type of media device

c. Adds media queries to the document

d. Defines background media for elements


Answer: b. Applies styles based on the type of media device

Which HTML tag is used for creating a table?

a. <table>

b. <tr>

c. <td>

d. <th>

Answer: a. <table>

What does the CSS property opacity control?

a. The thickness of the border

b. The transparency of an element

c. The font size

d. The color of the text

Answer: b. The transparency of an element

In HTML, the <aside> tag is used for:

a. Creating a sidebar

b. Adding a hyperlink

c. Defining a block of code

d. Embedding an external script

Answer: a. Creating a sidebar

Which of the following is the correct way to apply an inline CSS style?

a. <style>

b. <css>

c. <div style="...">

d. <link rel="stylesheet" type="text/css" href="style.css">

Answer: c. <div style="...">


What is the purpose of the CSS box-sizing property?

a. Sets the color of the box

b. Adjusts the size of the box model

c. Controls the spacing within the box

d. Defines how the total width and height of an element is calculated

Answer: d. Defines how the total width and height of an element is calculated

Which HTML tag is used to create a hyperlink to another webpage in a new browser window or tab?

a. <a target="_blank" href="...">

b. <a href="..." target="_new">

c. <a href="..." new-tab>

d. <a target="new" href="...">

Answer: a. <a target="_blank" href="...">

In CSS, what property is used to control the space between the content and the border of an element?

a. border-spacing

b. margin

c. padding

d. spacing

Answer: c. padding

What does the HTML <abbr> tag represent?

a. Abbreviation or acronym

b. Abstract

c. Absolute

d. Abbreviated link

Answer: a. Abbreviation or acronym


Which CSS property is used to change the style of a list item bullet?

a. list-style-image

b. list-style-type

c. list-item-style

d. list-bullet-style

Answer: b. list-style-type

In HTML, what does the <cite> tag represent?

a. A citation or reference to another source

b. A section of code

c. A bold text

d. A container for navigational links

Answer: a. A citation or reference to another source

What is the purpose of the CSS max-width property?

a. Sets the maximum height of an element

b. Defines the maximum width of an element

c. Controls the maximum font size

d. Adjusts the maximum spacing within an element

Answer: b. Defines the maximum width of an element

Which HTML tag is used for embedding an image?

a. <img>

b. <image>

c. <picture>

d. <img src="...">

Answer: a. <img>

In CSS, what property is used to set the color of visited hyperlinks?


a. link-color

b. visited-color

c. active-color

d. color-visited

Answer: b. visited-color

What is the purpose of the HTML <nav> tag?

a. Defines a section of navigation links

b. Contains the main content of the HTML document

c. Specifies the navigation bar

d. Adds a hyperlink to another webpage

Answer: a. Defines a section of navigation links

In CSS, the font-style: italic; property is used for:

a. Making the text bold

b. Adding an underline to the text

c. Setting the font style to italic

d. Changing the font color

Answer: c. Setting the font style to italic

What does the CSS property text-transform: uppercase; do?

a. Converts text to uppercase

b. Converts text to lowercase

c. Adjusts the letter spacing

d. Adds an underline to the text

Answer: a. Converts text to uppercase

In HTML, what does the <pre> tag define?

a. Preformatted text
b. A paragraph

c. A pre-header section

d. A pre-link element

Answer: a. Preformatted text

Which HTML tag is used for creating an ordered list?

a. <ol>

b. <ul>

c. <li>

d. <list>

Answer: a. <ol>

What is the purpose of the CSS float property?

a. Aligns text horizontally

b. Positions an element relative to its normal position

c. Floats an element to the right or left

d. Changes the font color

Answer: c. Floats an element to the right or left

In HTML, the <bdo> tag is used for:

a. Bold text

b. Bidirectional override for text direction

c. Background color override

d. Block display override

Answer: b. Bidirectional override for text direction

Which CSS property is used to control the size of an element's font?

a. font-size

b. text-size
c. font-style

d. text-font

Answer: a. font-size

In HTML, what is the purpose of the <head> tag?

a. Defines the main content of the HTML document

b. Contains metadata about the HTML document

c. Specifies the footer of the document

d. Creates a hyperlink

Answer: b. Contains metadata about the HTML document

What is the purpose of the HTML <mark> tag?

a. Marks an element as important or relevant

b. Adds a hyperlink

c. Defines a navigation link

d. Creates a list item

Answer: a. Marks an element as important or relevant

In CSS, the box-shadow property is used for:

a. Setting the box model properties

b. Adding a shadow to an element

c. Changing the background color

d. Controlling the spacing within the box

Answer: b. Adding a shadow to an element

Which HTML tag is used to define an input field for entering a date?

a. <input type="date">

b. <date>

c. <input type="text">
d. <textfield>

Answer: a. <input type="date">

In CSS, what property is used to set the thickness of an element's border?

a. border-width

b. border-thickness

c. border-size

d. thickness

Answer: a. border-width

Which HTML tag is used for creating a hyperlink to another webpage within the same website?

a. <a href="http://example.com">

b. <a href="/page2.html">

c. <a link="/page2.html">

d. <link href="/page2.html">

Answer: b. <a href="/page2.html">

What is the purpose of the HTML <figure> tag?

a. Defines a figure for a chart or graph

b. Specifies a figure for an image or illustration

c. Creates a figure for a block of code

d. Adds a figure for a list item

Answer: b. Specifies a figure for an image or illustration

In CSS, the text-decoration: underline; property is used for:

a. Controlling the space between lines of text

b. Adding an underline to the text

c. Setting the font style to underline

d. Changing the font color


Answer: b. Adding an underline to the text

What is the purpose of the HTML <main> tag?

a. Defines the main content of the HTML document

b. Specifies the navigation bar

c. Contains metadata about the HTML document

d. Creates a sidebar

Answer: a. Defines the main content of the HTML document

Which HTML tag is used for creating an italicized text?

a. <italic>

b. <i>

c. <em>

d. <italicize>

Answer: c. <em>

In CSS, the text-align: center; property is used for:

a. Aligning text horizontally to the left

b. Centering text horizontally

c. Aligning text horizontally to the right

d. Adjusting the spacing within the text

Answer: b. Centering text horizontally

What does the HTML <dfn> tag represent?

a. Definition term

b. Definition description

c. Divided format notation

d. Definition name

Answer: a. Definition term


In CSS, what property is used to change the style of a cursor when it hovers over a clickable element?

a. cursor-style

b. hover-cursor

c. mouse-cursor

d. cursor

Answer: d. cursor

Which HTML tag is used for creating a horizontal rule (line)?

a. <line>

b. <hr>

c. <rule>

d. <horizontal>

Answer: b. <hr>

What is the purpose of the HTML <aside> tag?

a. Defines a sidebar

b. Contains the main content of the HTML document

c. Adds a hyperlink

d. Specifies a footer

Answer: a. Defines a sidebar

In CSS, what property is used to control the spacing between lines of text?

a. line-spacing

b. text-spacing

c. line-height

d. text-height

Answer: c. line-height
What is the purpose of the HTML <figcaption> tag?

a. Adds a figure for an image or illustration

b. Defines a caption for a <figure> element

c. Specifies a footer for the document

d. Contains metadata about the HTML document

Answer: b. Defines a caption for a <figure> element

In CSS, what property is used to change the background color of an element when the user hovers over
it?

a. hover-background-color

b. background-color-hover

c. background-hover

d. background-color

Answer: a. hover-background-color

Which HTML tag is used for creating a subscript text?

a. <sub>

b. <sup>

c. <subscript>

d. <baseline>

Answer: a. <sub>

What is the purpose of the HTML <s> tag?

a. Defines a section of code

b. Specifies a strikethrough text

c. Defines a sidebar

d. Adds a hyperlink

Answer: b. Specifies a strikethrough text


In CSS, what property is used to control the space outside the border of an element?

a. border-spacing

b. margin

c. padding

d. spacing

Answer: b. margin

What does the CSS property overflow: hidden; do?

a. Hides the content that exceeds the specified height

b. Hides the content that exceeds the specified width

c. Hides the content that overflows both height and width

d. Hides the entire element

Answer: c. Hides the content that overflows both height and width

In HTML, what is the purpose of the <b> tag?

a. Adds a background color

b. Creates a bold text

c. Defines a block of code

d. Specifies a sidebar

Answer: b. Creates a bold text

Which CSS property is used for controlling the alignment of text within an element?

a. text-align

b. text-position

c. alignment

d. text-style

Answer: a. text-align

In HTML, what does the <wbr> tag do?


a. Represents a word break opportunity

b. Defines a webpage background

c. Wraps text in bold

d. Creates a new webpage

Answer: a. Represents a word break opportunity

Which CSS property is used to add a shadow to the text?

a. shadow-text

b. text-shadow

c. text-effect

d. text-outline

Answer: b. `text-shadow`

What does the CSS property position: fixed; do?

a. Positions an element relative to its normal position

b. Positions an element relative to the viewport

c. Floats an element to the right or left

d. Centers an element horizontally

makefile

Answer: b. Positions an element relative to the viewport

In HTML, what does the <var> tag represent?

a. A variable

b. A variant

c. A variation

d. A verified element

makefile

Answer: a. A variable
What is the purpose of the HTML <ruby> tag?

a. Defines a container for code

b. Specifies a ruby annotation for pronunciation

c. Creates a rule or line

d. Represents a regional sub-group

Answer: b. Specifies a ruby annotation for pronunciation

In CSS, what property is used to set the background color of an element when the user hovers over it?

a. hover-background-color

b. background-color-hover

c. background-hover

d. hover-color

Answer: a. `hover-background-color`

Which HTML tag is used for creating a horizontal line with a specific color?

a. <line>

b. <rule>

c. <hr color="...">

d. <horizontal>

Answer: c. `<hr color="...">`

What does the CSS property text-transform: capitalize; do?

a. Converts text to uppercase

b. Converts text to lowercase

c. Capitalizes the first letter of each word

d. Adds an underline to the text

sql

Answer: c. Capitalizes the first letter of each word


In HTML, what does the <kbd> tag represent?

a. Keyboard input

b. Key binding

c. Keyboard display

d. Keyboard description

Answer: a. Keyboard input

Which HTML tag is used for creating a superscript text?

a. <super>

b. <sup>

c. <superscript>

d. <baseline>

Answer: b. `<sup>`

What is the purpose of the HTML <time> tag?

a. Defines a timer

b. Represents a time or a range of time

c. Creates a timestamp

d. Sets the document creation time

Answer: b. Represents a time or a range of time

In CSS, what property is used to set the color of the text when the user hovers over it?

a. hover-text-color

b. color-hover

c. text-color-hover

d. hover-color

Answer: a. `hover-text-color`

Which HTML tag is used for creating an ordered list with lowercase Roman numerals?
a. <ol style="type: i;">

b. <ol type="I">

c. <ol style="list-style-type: lower-roman;">

d. <ol numeral-type="lower-roman">

Answer: c. `<ol style="list-style-type: lower-roman;">`

In CSS, what property is used to set the height of an element as a percentage of its containing element?

a. height

b. percentage-height

c. height-percentage

d. relative-height

Answer: a. `height`

What does the HTML <small> tag represent?

a. Defines small text

b. Specifies a small section of code

c. Creates a subscript text

d. Adds a small background color

Answer: a. Defines small text

In CSS, the clear: both; property is used for:

a. Clearing both the margin and padding

b. Clearing both the left and right floats

c. Clearing both the text and background color

d. Clearing both the border and shadow

Answer: b. Clearing both the left and right floats

Which HTML tag is used for creating a navigation bar?

a. <nav>
b. <navbar>

c. <bar>

d. <navigation>

Answer: a. `<nav>`

What is the purpose of the HTML <samp> tag?

a. Adds sample text

b. Defines a sample output from a program

c. Specifies a sample code snippet

d. Creates a sample image

csharp

Answer: b. Defines a sample output from a program

In CSS, what property is used to set the style of the list item marker (bullet or number)?

a. list-style-image

b. list-style-type

c. marker-style

d. item-style

Answer: b. `list-style-type`

Which HTML tag is used for creating a block of code?

a. <code>

b. <pre>

c. <block>

d. <text>

Answer: a. `<code>`

UNIT 4 MCQ
• What does CSS stand for?
o a) Computer Style Sheets
o b) Creative Style Sheets
o c) Cascading Style Sheets
o d) Colorful Style Sheets
o Answer: c
• Which HTML tag is used for creating a hyperlink?
o a) <link>
o b) <a>
o c) <url>
o d) <href>
o Answer: b
• In CSS, what property is used to set the background color of an element?
o a) color
o b) background-color
o c) bgcolor
o d) background
o Answer: b
• What is the purpose of the HTML alt attribute in the <img> tag?
o a) Sets the alignment of the image
o b) Defines the alternative text for the image
o c) Specifies the image source
o d) Controls the image width
o Answer: b
• Which CSS property is used to control the space between elements' outer
edges and the surrounding elements?
o a) margin
o b) padding
o c) spacing
o d) border
o Answer: a
• What is the purpose of the HTML <head> tag?
o a) Defines the main content of the document
o b) Contains metadata about the document
o c) Creates a header section in the document
o d) Specifies the font for the document
o Answer: b
• Which HTML tag is used for creating a line break?
o a) <br>
o b) <lb>
o c) <newline>
o d) <break>
o Answer: a
• In CSS, what is the purpose of the position: relative; property?
o a) Positions the element absolutely
o b) Positions the element relative to its normal position
o c) Removes the element from the normal document flow
o d) Hides the element
o Answer: b
• Which of the following is NOT a valid CSS pseudo-class?
o a) :hover
o b) :active
o c) :visible
o d) :focus
o Answer: c
• What does the acronym URL stand for?
o a) Uniform Resource Locator
o b) Universal Reference Language
o c) User-Defined Resource Locator
o d) Unified Resource Language
o Answer: a
• What does HTML stand for?
o a) Hyper Transfer Markup Language
o b) Hyper Text Markup Language
o c) Hyperlink and Text Markup Language
o d) High-Level Text Markup Language
o Answer: b
• Which HTML tag is used for creating an ordered list?
o a) <ol>
o b) <ul>
o c) <li>
o d) <list>
o Answer: a
• In CSS, what property is used to control the spacing between lines of text?
o a) line-height
o b) spacing
o c) text-spacing
o d) letter-spacing
o Answer: a
• What is the purpose of the CSS z-index property?
o a) Controls the opacity of an element
o b) Controls the stacking order of elements
o c) Sets the width of an element
o d) Defines the zoom level of an element
o Answer: b
• Which of the following is NOT a valid value for the display property in CSS?
o a) block
o b) inline
o c) hidden
o d) vertical
o Answer: d
• What is the purpose of the HTML <meta> tag with the charset attribute?
o a) Defines the character set for the document
o b) Creates a meta description for search engines
o c) Specifies the font charset
o d) Sets the document language
o Answer: a
• Which CSS selector is more specific?
o a) class selector (e.g., .my-class)
o b) ID selector (e.g., #my-id)
o c) Element selector (e.g., p)
o d) Attribute selector (e.g., [type="text"])
o Answer: b
• In HTML, which tag is used for embedding an image?
o a) <img>
o b) <picture>
o c) <image>
o d) <imgsrc>
o Answer: a
• What is the purpose of the CSS box-sizing property?
o a) Sets the color of the box border
o b) Defines the box model for an element
o c) Controls the box shadow
o d) Specifies the box layout
o Answer: b
• Which of the following is the correct way to link an external CSS file to an
HTML document?
o a) <link rel="stylesheet" type="text/css" href="style.css">
o b) <style src="style.css"></style>
o c) <css>style.css</css>
o d) <link href="style.css" type="stylesheet">
o Answer: a
• What does CSS stand for?
o a) Computer Style Sheets
o b) Creative Style Sheets
o c) Cascading Style Sheets
o d) Colorful Style Sheets
o Answer: c
• Which HTML tag is used for creating a hyperlink?
o a) <link>
o b) <a>
o c) <url>
o d) <href>
o Answer: b
• In CSS, what property is used to set the background color of an element?
o a) color
o b) background-color
o c) bgcolor
o d) background
o Answer: b
• What is the purpose of the HTML alt attribute in the <img> tag?
o a) Sets the alignment of the image
o b) Defines the alternative text for the image
o c) Specifies the image source
o d) Controls the image width
o Answer: b
• Which CSS property is used to control the space between elements' outer
edges and the surrounding elements?
o a) margin
o b) padding
o c) spacing
o d) border
o Answer: a
• What is the purpose of the HTML <head> tag?
o a) Defines the main content of the document
o b) Contains metadata about the document
o c) Creates a header section in the document
o d) Specifies the font for the document
o Answer: b
• Which HTML tag is used for creating a line break?
o a) <br>
o b) <lb>
o c) <newline>
o d) <break>
o Answer: a
• In CSS, what is the purpose of the position: relative; property?
o a) Positions the element absolutely
o b) Positions the element relative to its normal position
o c) Removes the element from the normal document flow
o d) Hides the element
o Answer: b
• Which of the following is NOT a valid CSS pseudo-class?
o a) :hover
o b) :active
o c) :visible
o d) :focus
o Answer: c
• What does the acronym URL stand for?
o a) Uniform Resource Locator
o b) Universal Reference Language
o c) User-Defined Resource Locator
o d) Unified Resource Language
o Answer: a
• In HTML, which tag is used for creating a table?
o a) <table>
o b) <tab>
o c) <tr>
o d) <td>
o Answer: a
• Which CSS property is used for adding shadows to text?
o a) text-shadow
o b) shadow
o c) font-shadow
o d) box-shadow
o Answer: a
• What is the purpose of the HTML <nav> element?
o a) Defines a navigation menu
o b) Specifies a new navigation page
o c) Creates a navigation link
o d) Defines a navigation bar
o Answer: a
• In CSS, how can you select all the elements with a class name "example"?
o a) .example
o b) #example
o c) element.example
o d) example
o Answer: a
• What is the default value of the CSS position property?
o a) absolute
o b) relative
o c) fixed
o d) static
o Answer: d
• Which HTML tag is used for creating a form?
o a) <form>
o b) <input>
o c) <button>
o d) <label>
o Answer: a
• In CSS, what does the float property do?
o a) Makes an element float to the left or right
o b) Adds a floating effect to an element
o c) Floats an element above other elements
o d) Makes an element semi-transparent
o Answer: a
• What does the HTML <aside> element represent?
o a) A footer section
o b) A side note or content that is tangentially related to the content around it
o c) A header section
o d) An article or content that is independent of the surrounding content
o Answer: b
• Which CSS property is used to set the size of the font?
o a) text-size
o b) font-size
o c) size
o d) text-font
o Answer: b
• What is the purpose of the HTML <article> element?
o a) Defines an article
o b) Creates a section in the document
o c) Represents a side note or additional information
o d) Defines a container for navigation links
o Answer: a
• In CSS, what is the purpose of the max-width property?
o a) Sets the maximum width of an element
o b) Sets the minimum width of an element
o c) Controls the width of the document
o d) Specifies the maximum width of the viewport
o Answer: a
• What is the purpose of the HTML target attribute in the <a> tag?
o a) Specifies the URL of the link
o b) Defines the target audience of the link
o c) Controls how the link should open
o d) Sets the position of the link
o Answer: c
• Which CSS property is used to create space around an element's content,
inside of any defined borders?
o a) margin
o b) padding
o c) spacing
o d) border-spacing
o Answer: b
• In HTML, what does the <figure> element represent?
o a) A group of images
o b) A caption for an image or illustration
o c) A figure or image with a caption
o d) A container for navigation links
o Answer: c
• Which CSS property is used to change the text color of an element?
o a) text-color
o b) color
o c) font-color
o d) text-style
o Answer: b
• What is the purpose of the HTML target attribute in the <form> tag?
o a) Specifies the method of the form
o b) Defines the target audience of the form
o c) Controls how the form data should be submitted
o d) Sets the position of the form
o Answer: c
• In CSS, what does the opacity property control?
o a) The size of an element
o b) The transparency of an element
o c) The shadow of an element
o d) The color of an element
o Answer: b
• Which HTML tag is used for creating an input field for entering a date?
o a) <input type="text">
o b) <input type="date">
o c) <date>
o d) <input type="datetime">
o Answer: b
• What is the purpose of the CSS flexbox layout model?
o a) To create a grid layout
o b) To create a flexible box model for layout design
o c) To control the font size
o d) To add shadows to text
o Answer: b
• In HTML, what does the <blockquote> element represent?
o a) A block of code
o b) A block-level quotation
o c) A block of text with a specific style
o d) A block of images
o Answer: b
• Which CSS property is used to change the style of the cursor when hovered
over an element?
o a) cursor-style
o b) pointer-style
o c) hover-cursor
o d) cursor
o Answer: d
• In CSS, what is the purpose of the transition property?
o a) Adds a transition effect to an element
o b) Sets the transition duration
o c) Controls the timing function of a transition
o d) All of the above
o Answer: d
• What is the purpose of the HTML datetime attribute in the <time> tag?
o a) Specifies the time zone
o b) Defines the date and time
o c) Sets the font size
o d) Controls the text alignment
o Answer: b
• Which HTML tag is used for creating a dropdown list?
o a) <dropdown>
o b) <select>
o c) <list>
o d) <options>
o Answer: b
• In CSS, what is the purpose of the box-shadow property?
o a) Adds a shadow to an element
o b) Sets the background color of an element
o c) Controls the width of an element
o d) Defines the box model for an element
o Answer: a
• What does the acronym API stand for in web development?
o a) Advanced Programming Interface
o b) Application Programming Interface
o c) Advanced Protocol Integration
o d) Application Protocol Interface
o Answer: b
• Which HTML tag is used for creating a checkbox?
o a) <checkbox>
o b) <input type="checkbox">
o c) <check>
o d) <input type="check">
o Answer: b
• Which of the following is NOT a valid CSS unit for specifying length?
o a) px (pixels)
o b) em
o c) pt (points)
o d) ex
o Answer: d
• What is the purpose of the HTML <iframe> element?
o a) Defines an inline frame for embedding external content
o b) Creates a floating image
o c) Specifies the font style for text
o d) Defines an internal frame for navigation
o Answer: a
• In CSS, what is the purpose of the flex-grow property?
o a) Specifies the initial size of a flex container
o b) Controls the growth factor of a flex item
o c) Sets the flexibility of an element
o d) Determines the size of a flex item relative to other items
o Answer: b
• What is the purpose of the HTML placeholder attribute in the <input> tag?
o a) Sets the initial value of the input field
o b) Defines a hint to the user about the expected value of the input
o c) Controls the font style of the input text
o d) Specifies the maximum length of the input field
o Answer: b
• Which CSS property is used to create rounded corners?
o a) border-radius
o b) corner-radius
o c) curve-radius
o d) box-radius
o Answer: a
• In HTML, what is the purpose of the <abbr> element?
o a) Defines an abbreviation or acronym
o b) Creates a hyperlink
o c) Specifies the alignment of text
o d) Defines a block of code
o Answer: a
• What is the purpose of the CSS transform property?
o a) Changes the position of an element
o b) Applies a 3D transformation to an element
o c) Rotates an element
o d) All of the above
o Answer: d
• In HTML, which attribute is used to provide additional information about an
element, such as a tooltip?
o a) info
o b) tooltip
o c) title
o d) description
o Answer: c
• What is the purpose of the CSS transition-timing-function property?
o a) Sets the duration of a transition
o b) Specifies the starting point of a transition
o c) Controls the timing function of a transition
o d) Defines the easing function of a transition
o Answer: d
• Which HTML tag is used for creating a radio button?
o a) <radio>
o b) <input type="radio">
o c) <option>
o d) <input type="option">
o Answer: b
• In CSS, what is the purpose of the text-transform property?
o a) Transforms the background color of text
o b) Transforms the text size
o c) Controls the transformation of text content
o d) Transforms the text case
o Answer: d
• What is the purpose of the HTML disabled attribute in form elements?
o a) Disables the autofocus for the input element
o b) Disables the input element
o c) Specifies the default value for the input element
o d) Disables the required attribute for the input element
o Answer: b
• Which CSS property is used to set the style of the list item marker (bullet or
number)?
o a) list-style-type
o b) marker-style
o c) item-style
o d) list-marker
o Answer: a
• What is the purpose of the HTML accesskey attribute?
o a) Sets the shortcut key for an element
o b) Specifies the access level of an element
o c) Defines the hyperlink key
o d) Controls the access to the document
o Answer: a
• In CSS, what is the purpose of the background-size property?
o a) Controls the background color of an element
o b) Sets the size of the background image
o c) Specifies the background position
o d) Defines the background attachment
o Answer: b
• What is the purpose of the HTML target="_blank" attribute in the <a> tag?
o a) Opens the link in a new window or tab
o b) Sets the target audience for the link
o c) Targets the link to a specific frame
o d) Specifies the link's accessibility
o Answer: a
• Which HTML tag is used for creating a horizontal rule?
o a) <hr>
o b) <line>
o c) <rule>
o d) <horizontal>
o Answer: a
• In CSS, what does the display: flex; property do?
o a) Enables the flex container for the element
o b) Displays the element as an inline element
o c) Controls the display of the element
o d) Sets the element to be hidden
o Answer: a
• What is the purpose of the HTML required attribute in form elements?
o a) Specifies that the input field must be filled out before submitting the form
o b) Sets the default value for the input element
o c) Defines the maximum length of the input field
o d) Specifies the required option for the form
o Answer: a
• Which CSS property is used to create a responsive design by allowing elements
to shrink or grow based on the available space?
o a) responsiveness
o b) flex-grow
o c) responsive-layout
o d) media-query
o Answer: b
• In HTML, what does the <datalist> element provide?
o a) A list of data items for autocomplete suggestions
o b) A list of data sources for an external database
o c) A list of datatypes for form validation
o d) A list of data attributes for metadata
o Answer: a
• What is the purpose of the CSS :nth-child() pseudo-class?
o a) Selects elements based on their position within a parent
o b) Selects elements with a specific class
o c) Targets the first child element
o d) Applies styles to all child elements
o Answer: a
• Which HTML tag is used for creating a hyperlink that links to an email
address?
o a) <email>
o b) <link>
o c) <a>
o d) <mail>
o Answer: c
• In CSS, what is the purpose of the word-wrap property?
o a) Controls the word spacing in text
o b) Wraps long words to the next line to prevent overflow
o c) Specifies the word count in a paragraph
o d) Sets the word alignment in a container
o Answer: b
• What does the acronym CDN stand for in web development?
o a) Central Development Network
o b) Content Delivery Network
o c) Code Development Network
o d) Cached Data Network
o Answer: b
• Which HTML tag is used for creating an unordered list?
o a) <ol>
o b) <ul>
o c) <li>
o d) <list>
o Answer: b
• In CSS, what does the object-fit property do?
o a) Adjusts the size of the object
o b) Controls the positioning of the object within its container
o c) Defines the object's color
o d) Applies a filter to the object
o Answer: b
• What is the purpose of the HTML srcset attribute in the <img> tag?
o a) Sets the source of the image
o b) Specifies the size of the image
o c) Defines a list of possible image sources
o d) Adds a shadow to the image
o Answer: c
• Which CSS property is used to create a sticky element that remains fixed
during scrolling?
o a) position: fixed;
o b) position: sticky;
o c) position: absolute;
o d) position: relative;
o Answer: b
• In HTML, what is the purpose of the <cite> element?
o a) Represents a citation or reference to a creative work
o b) Creates a hyperlink
o c) Defines a block of code
o d) Specifies the citation style for a document
o Answer: a
• What is the purpose of the CSS currentColor keyword?
o a) Sets the current font color
o b) Specifies the color of the current element
o c) Defines the current font size
o d) Controls the background color of the current element
o Answer: b
• Which HTML tag is used for creating a range input slider?
o a) <slider>
o b) <input type="range">
o c) <range>
o d) <input type="slider">
o Answer: b
• What is the purpose of the colspan attribute in HTML tables?
o a) Sets the color of a table cell
o b) Specifies the number of columns a cell should span
o c) Defines the border style of a table
o d) Indicates the type of content in a cell
o Answer: b
• How do you apply CSS styles to a specific table in HTML?
o a) Using the <table-style> tag
o b) Applying styles directly to <tr> elements
o c) Using the <style> tag within the <table> element
o d) Assigning a class or ID to the <table> element
o Answer: d
• What does the CSS property border-collapse control in tables?
o a) The spacing between table cells
o b) The visibility of table borders
o c) The collapsing of table borders
o d) The alignment of table content
o Answer: c
• How can you create a hover effect on table rows using CSS?
o a) Applying :hover to <td> elements
o b) Using the hover class on the table
o c) Applying :hover to <tr> elements
o d) Adding a hover attribute to the <table> tag
o Answer: c
• In HTML tables, what does the rowspan attribute determine?
o a) The color of a table row
o b) The height of a table row
o c) The number of rows a cell should span
o d) The content of a table row
o Answer: c

Forms:
• What is the purpose of the HTML action attribute in a form tag?
o a) Defines the form's action when a button is clicked
o b) Specifies the URL where the form data should be submitted
o c) Sets the form's method to either get or post
o d) Controls the alignment of form elements
o Answer: b
• In HTML forms, what does the enctype attribute define?
o a) The type of encoding used for form data
o b) The alignment of form controls
o c) The encryption level of form data
o d) The type of input expected in the form
o Answer: a
• Which HTML element is used for creating a text input field in a form?
o a) <text>
o b) <input type="text">
o c) <textbox>
o d) <textfield>
o Answer: b
• What is the purpose of the HTML <textarea> element in a form?
o a) Creates a text input field
o b) Defines a dropdown box
o c) Allows multiline text input
o d) Specifies a password input field
o Answer: c
• In HTML forms, what does the method attribute define?
o a) The form's width
o b) The type of data submission (get or post)
o c) The form's action URL
o d) The form's encoding type
o Answer: b
• Which HTML tag is used for creating a checkbox in a form?
o a) <check>
o b) <input type="checkbox">
o c) <box>
o d) <checkbox>
o Answer: b
• What is the purpose of the HTML placeholder attribute in form inputs?
o a) Specifies a default value for the input
o b) Defines a hint for expected input
o c) Sets the input field's width
o d) Controls the font style of the input text
o Answer: b
• Which HTML element is used for creating a dropdown list?
o a) <dropdown>
o b) <list>
o c) <select>
o d) <options>
o Answer: c
• What is the purpose of the HTML required attribute in form elements?
o a) Specifies the default value for the input element
o b) Sets the maximum length of the input field
o c) Requires that the input field must be filled out before submitting the form
o d) Controls the form's accessibility
o Answer: c
• In HTML forms, what does the autocomplete attribute control?
o a) Autocomplete options for the form
o b) The form's action URL
o c) The input field's width
o d) The form's encoding type
o Answer: a

CSS Grids and Webpage Layouts:


• What is the main purpose of CSS Grid layout?
o a) To create a flexible box model
o b) To design responsive web pages
o c) To define a two-dimensional grid-based layout
o d) To apply styles to form elements
o Answer: c
• Which CSS property is used to create a grid container?
o a) grid-container
o b) grid-box
o c) grid-layout
o d) display: grid;
o Answer: d
• In CSS Grid, what is the purpose of the grid-template-rows property?
o a) Sets the color of the grid rows
o b) Defines the size of the grid rows
o c) Specifies the alignment of grid items
o d) Controls the spacing between grid rows
o Answer: b
• Which CSS property is used to create a responsive layout by allowing elements
to shrink or grow based on the available space?
o a) flex-shrink
o b) grid-grow
o c) flex-grow
o d) grid-auto-flow
o Answer: a
• What is the purpose of the CSS property grid-column?
o a) Defines the size of the grid columns
o b) Specifies the placement of grid items in the columns
o c) Controls the visibility of the grid columns
o d) Sets the background color of the grid columns
o Answer: b
• In CSS Grid, what does the grid-template-areas property define?
o a) Sets the color of the grid areas
o b) Defines named grid areas
o c) Specifies the placement of grid items in areas
o d) Controls the size of the grid areas
o Answer: b
• Which CSS property is used to create a fixed-size grid track?
o a) grid-template-columns
o b) grid-track-size
o c) grid-fixed-size
o d) grid-column
o Answer: a
• What is the purpose of the CSS property grid-auto-flow?
o a) Controls the flow of grid items within the grid container
o b) Sets the background color of the grid container
o c) Specifies the alignment of the grid container
o d) Defines the size of the grid container
o Answer: a
• In CSS Grid, what does the justify-items property do?
o a) Aligns grid items along the inline axis
o b) Aligns grid items along the block axis
o c) Aligns grid items within a grid area
o d) Justifies the content of grid items
o Answer: a
• What is the purpose of the CSS property grid-gap in a grid layout?
o a) Defines the gap between grid items
o b) Sets the color of the grid lines
o c) Controls the spacing between grid tracks
o d) Specifies the alignment of grid items
o Answer: c
• Which CSS property is used to create a responsive design by allowing elements
to be arranged based on media queries?
o a) grid-template-rows
o b) grid-auto-flow
o c) display: grid;
o d) media-query: grid;
o Answer: b
• In CSS Grid, what does the place-items property do?
o a) Places grid items within the grid container
o b) Sets the alignment of grid items along the block axis
o c) Aligns the content of grid items
o d) Controls the visibility of grid items
o Answer: a
• What is the purpose of the CSS property grid-template-columns?
o a) Sets the color of the grid columns
o b) Defines the size of the grid columns
o c) Specifies the placement of grid items in columns
o d) Controls the spacing between grid columns
o Answer: b
• In CSS Grid, what does the align-self property do?
o a) Aligns the grid items along the inline axis
o b) Aligns the grid items along the block axis
o c) Aligns a single grid item within its grid area
o d) Aligns the content of grid items
o Answer: c
• Which CSS property is used to create a fixed-size grid row or column?
o a) grid-row
o b) grid-track-size
o c) grid-auto-rows
o d) grid-row-gap
o Answer: b

UNIT 5 MCQ

What is the correct way to include an external JavaScript file in an HTML document?

a. <script src="script.js"></script>

b. <include src="script.js">

c. <javascript href="script.js"></javascript>

d. <link rel="script" href="script.js">

Answer: a

How do you declare a variable in JavaScript?

a. variable x;

b. var x;

c. x = variable;
d. declare x;

Answer: b

What is the purpose of the === operator in JavaScript?

a. Assignment

b. Equality (value and type)

c. Less than

d. Greater than or equal to

Answer: b

In JavaScript, what is the purpose of the break statement?

a. Skip to the next iteration of a loop

b. Exit a switch statement

c. Terminate the script

d. Create a line break in the code

Answer: b

What is the correct syntax for a for loop in JavaScript?

a. for (i = 0; i < 10; i++) {}

b. for (let i = 0; i < 10; i++) {}

c. for i = 0; i < 10; i++ {}

d. loop (i = 0; i < 10; i++) {}

Answer: b

Which of the following is NOT a valid JavaScript variable name?

a. myVar

b. 2ndVar

c. _variable

d. $price
Answer: b

What is the purpose of the alert function in JavaScript?

a. Display a prompt for user input

b. Display a message box with an OK button

c. Print a message to the console

d. Display a confirmation dialog

Answer: b

How can you comment out a single line in JavaScript?

a. /* This is a comment */

b. <!-- This is a comment -->

c. # This is a comment

d. // This is a comment

Answer: d

Which of the following is a valid way to create an array in JavaScript?

a. arr = [1, 2, 3];

b. arr = {1, 2, 3};

c. arr = new Array(1, 2, 3);

d. All of the above

Answer: a

What is the purpose of the confirm function in JavaScript?

a. Display a message box with an OK button

b. Display a prompt for user input

c. Display a confirmation dialog with OK and Cancel buttons

d. Print a message to the console

Answer: c
How can you define a function in JavaScript?

a. function = myFunction() {}

b. define myFunction() {}

c. function myFunction() {}

d. create myFunction() {}

Answer: c

What is the purpose of the else statement in JavaScript?

a. To end the execution of a loop

b. To define the default case in a switch statement

c. To specify the action if the condition in an if statement is false

d. To continue to the next iteration of a loop

Answer: c

Which of the following is an example of a JavaScript event?

a. onInput

b. onClick

c. onChange

d. All of the above

Answer: d

What does the this keyword refer to in JavaScript?

a. The current function

b. The global object

c. The object that owns the current function

d. The next iteration of a loop

Answer: c

What is the purpose of the return statement in a JavaScript function?


a. To exit the function

b. To return a value from the function

c. To break out of a loop

d. To display a message box

Answer: b

Which operator is used for string concatenation in JavaScript?

a. +

b. -

c. *

d. /

Answer: a

What is the correct way to write a comment that spans multiple lines in JavaScript?

a. /* This is a comment */

b. <!-- This is a comment -->

c. # This is a comment

d. // This is a comment

Answer: a

How can you convert a string to an integer in JavaScript?

a. parseInt("42")

b. convertToInt("42")

c. strToNum("42")

d. toInteger("42")

Answer: a

In a switch statement, what happens if no case matches the switch expression?

a. The code inside the switch statement is skipped.


b. The first case is executed.

c. The default case is executed.

d. An error is thrown.

Answer: c

What is the purpose of the continue statement in a loop?

a. To exit the loop

b. To skip the rest of the code in the loop and move to the next iteration

c. To break out of the loop

d. To restart the loop from the beginning

Answer: b

How do you declare a constant variable in JavaScript?

a. constant x = 10;

b. const x = 10;

c. let x = 10;

d. var x = 10;

Answer: b

What is the purpose of the indexOf method in JavaScript?

a. To find the index of the first occurrence of a specified value in a string

b. To find the index of the last occurrence of a specified value in an array

c. To find the index of the current element in a loop

d. To find the index of a specific element in an object

Answer: a

Which of the following is an example of a falsy value in JavaScript?

a. 0

b. null
c. false

d. All of the above

Answer: d

What is the purpose of the splice method in JavaScript?

a. To add elements to an array

b. To remove elements from an array

c. To reverse the elements of an array

d. To sort the elements of an array

Answer: b

How do you prevent a form from submitting in JavaScript?

a. event.preventDefault();

b. form.preventSubmit();

c. form.cancelSubmit();

d. event.cancelSubmission();

Answer: a

What is the purpose of the onkeydown event in JavaScript?

a. Triggered when a key is pressed down

b. Triggered when a key is released

c. Triggered when a key is clicked

d. Triggered when a key is double-clicked

Answer: a

Which method is used to add an element to the end of an array in JavaScript?

a. push()

b. add()

c. append()
d. insert()

Answer: a

How do you round a number to the nearest integer in JavaScript?

a. Math.round()

b. Math.floor()

c. Math.ceil()

d. Math.random()

Answer: a

What does the localStorage object in JavaScript allow you to do?

a. Store data that persists even after the browser is closed

b. Access the current location of the user

c. Execute functions asynchronously

d. Manage the layout of a webpage

Answer: a

What is the purpose of the addEventListener method in JavaScript?

a. To add a new event to an HTML element

b. To listen for a specific event on an HTML element and execute a function

c. To remove an event listener from an HTML element

d. To create a new event handler function

Answer: b

How do you convert a string to lowercase in JavaScript?

a. str.lowerCase()

b. toLowerCase(str)

c. str.toLower()

d. str.toLowerCase()
Answer: d

What is the purpose of the NaN value in JavaScript?

a. It represents a valid number

b. It stands for "Not a Number" and is used to indicate an undefined or unrepresentable value

c. It is a shorthand for "Negative and Negative"

d. It is a keyword for defining a new number

Answer: b

What is the purpose of the Array.isArray method in JavaScript?

a. To check if an object is an array

b. To convert an array to a string

c. To reverse the order of elements in an array

d. To remove duplicate elements from an array

Answer: a

How can you dynamically change the content of an HTML element using JavaScript?

a. document.getElementContentById('myElement').innerHTML = 'New content';

b. document.getElementById('myElement').innerText = 'New content';

c. document.getElement('myElement').content = 'New content';

d. document.setElementContent('myElement', 'New content');

Answer: b

What is the purpose of the setTimeout function in JavaScript?

a. To define a timeout for a function to be executed after a specified time

b. To create a delay in the execution of the entire script

c. To set the duration of a transition in CSS

d. To measure the time it takes for a function to execute

Answer: a
How do you remove the first element from an array in JavaScript?

a. array.delete(0);

b. array.shift();

c. array.remove(0);

d. array.splice(0, 1);

Answer: b

What is the purpose of the target property in a JavaScript event?

a. To specify the type of event

b. To identify the source of the event

c. To define the target element for an animation

d. To control the propagation of the event

Answer: b

How do you check if a variable is undefined in JavaScript?

a. if (variable == undefined)

b. if (variable === undefined)

c. if (undefined(variable))

d. if (isUndefined(variable))

Answer: b

What is the purpose of the pop method in JavaScript?

a. To remove the last element from an array

b. To add an element to the end of an array

c. To reverse the order of elements in an array

d. To check if an array is empty

Answer: a
How do you access the value of an input field in JavaScript?

a. document.inputValue('myInput')

b. document.getElement('myInput').value

c. document.getElementById('myInput').getValue()

d. document.getElementById('myInput').value

Answer: d

What does the Math.random() function in JavaScript return?

a. A random integer between 1 and 100

b. A random floating-point number between 0 (inclusive) and 1 (exclusive)

c. A random number with a normal distribution

d. The mathematical constant π (pi)

Answer: b

How do you check if a number is an integer in JavaScript?

a. Number.isInteger()

b. isInt()

c. Math.isInteger()

d. typeof(number) === 'integer'

Answer: a

What is the purpose of the encodeURIComponent function in JavaScript?

a. To encode a URI component

b. To decode a URI component

c. To check if a URI is valid

d. To convert a string to lowercase

Answer: a

How can you iterate over the properties of an object in JavaScript?


a. Using a for loop

b. Using the forEach method

c. Using the map method

d. All of the above

Answer: d

What is the purpose of the event.stopPropagation() method in JavaScript?

a. To stop the execution of the entire script

b. To prevent the default action associated with an event from being triggered

c. To stop the propagation of the event to parent elements

d. To stop the execution of a specific function

Answer: c

How do you convert a number to a string in JavaScript?

a. String(number)

b. number.toString()

c. "" + number

d. All of the above

Answer: d

Which of the following is a valid JavaScript regular expression?

a. /[a-z]/

b. regex("[a-z]")

c. RegExp("[a-z]")

d. All of the above

Answer: a

What does the slice method do in JavaScript?

a. Removes the last element from an array


b. Returns a portion of an array as a new array

c. Adds elements to the end of an array

d. Converts an array to a string

Answer: b

How do you check the type of a variable in JavaScript?

a. typeOf variable

b. typeof variable

c. type(variable)

d. variable.type()

Answer: b

In JavaScript, what is the purpose of the onsubmit event?

a. Triggered when a key is pressed

b. Triggered when a form is submitted

c. Triggered when the page is loaded

d. Triggered when a button is clicked

Answer: b

What is the purpose of the querySelector method in JavaScript?

a. To select the first element that matches a specified CSS selector

b. To select all elements that match a specified CSS selector

c. To select the parent element of a specified element

d. To select the next sibling element of a specified element

Answer: a

How do you convert a string to an array in JavaScript?

a. str.toArray()

b. Array.from(str)
c. str.split('')

d. All of the above

Answer: c

What is the purpose of the onmouseover event in JavaScript?

a. Triggered when the mouse pointer moves out of an element

b. Triggered when the mouse pointer moves over an element

c. Triggered when a key is pressed

d. Triggered when a form is submitted

Answer: b

How do you check if an element has a specific class in JavaScript?

a. element.checkClass('myClass')

b. element.contains('myClass')

c. element.hasClass('myClass')

d. element.isClass('myClass')

Answer: b

What is the purpose of the reduce method in JavaScript?

a. To add elements to an array

b. To remove elements from an array

c. To combine the elements of an array into a single value

d. To reverse the order of elements in an array

Answer: c

How do you create a new date object representing the current date and time in JavaScript?

a. new Date()

b. new Date().now()
c. Date.current()

d. createDate()

Answer: a

What is the purpose of the appendChild method in JavaScript?

a. To remove an element from the DOM

b. To add a new child element to an existing element

c. To check if an element has a specific attribute

d. To select the parent element of a specified element

Answer: b

How do you remove an attribute from an HTML element using JavaScript?

a. element.removeAttr('attributeName')

b. element.removeAttribute('attributeName')

c. element.deleteAttr('attributeName')

d. element.remove('attributeName')

Answer: b

What is the purpose of the fetch function in JavaScript?

a. To fetch data from a server using AJAX

b. To create a new array from an existing array

c. To fetch elements from the DOM

d. To fetch random values from an array

Answer: a

How do you check if a value is included in an array in JavaScript?

a. array.includes(value)

b. array.contains(value)

c. array.hasValue(value)
d. array.indexOf(value) !== -1

Answer: a

What is the purpose of the localStorage.setItem method in JavaScript?

a. To retrieve an item from local storage

b. To add an item to local storage

c. To remove an item from local storage

d. To clear all items from local storage

Answer: b

How do you convert a string to uppercase in JavaScript?

a. toUpperCase(str)

b. str.toUpper()

c. str.toUpperCase()

d. convertToUpper(str)

Answer: c

What is the purpose of the event.preventDefault method in JavaScript?

a. To stop the execution of the entire script

b. To prevent the default action associated with an event

c. To stop the propagation of the event to parent elements

d. To create a default action for an event

Answer: b

How can you check the length of an array in JavaScript?

a. array.len()

b. array.length

c. length(array)

d. len(array)
Answer: b

What does the JSON.parse function in JavaScript do?

a. Parses a JSON string and returns a JavaScript object

b. Converts a JavaScript object to a JSON string

c. Checks if a variable is a JSON object

d. Deletes a property from a JSON object

Answer: a

In JavaScript, what is the purpose of the toFixed method?

a. Rounds a number to the nearest integer

b. Converts a number to a fixed-point notation string

c. Returns the square root of a number

d. Converts a number to a floating-point notation string

Answer: b

How can you check if a variable is an array in JavaScript?

a. isArray(variable)

b. variable.isArray()

c. Array.check(variable)

d. variable.isTypeOf(Array)

Answer: a

What is the purpose of the map method in JavaScript?

a. To create a new array with the results of calling a provided function on every element in the array

b. To remove elements from an array

c. To reverse the order of elements in an array

d. To add elements to the end of an array

Answer: a
How do you declare a function expression in JavaScript?

a. function myFunction() {}

b. var myFunction = function() {}

c. const myFunction = function() {}

d. Both b and c

Answer: d

What is the purpose of the bind method in JavaScript?

a. To bind a function to a specific element

b. To create a new function with a specific context and parameters

c. To check if a function is already bound

d. To remove a function from an object

Answer: b

How do you compare two objects for equality in JavaScript?

a. object1 == object2

b. object1.equals(object2)

c. Object.equals(object1, object2)

d. There is no built-in way to compare objects for equality

Answer: d

What is the purpose of the splice method in JavaScript arrays?

a. To add elements to the beginning of an array

b. To remove elements from the middle of an array

c. To reverse the order of elements in an array

d. To sort the elements of an array

Answer: b
How do you round a number down to the nearest integer in JavaScript?

a. Math.floor()

b. Math.round()

c. Math.ceil()

d. Math.trunc()

Answer: a

In JavaScript, what is the purpose of the Object.keys method?

a. To retrieve all keys from an object

b. To add new keys to an object

c. To remove keys from an object

d. To check if a key exists in an object

Answer: a

What is the purpose of the onchange event in JavaScript?

a. Triggered when a key is pressed

b. Triggered when the value of an input changes

c. Triggered when the mouse pointer moves over an element

d. Triggered when a button is clicked

Answer: b

How do you create a new array by applying a function to each element of an existing array in JavaScript?

a. map()

b. filter()

c. reduce()

d. forEach()

Answer: a

What does the acronym "DOM" stand for in JavaScript?


a. Document Object Model

b. Display Object Model

c. Dynamic Object Model

d. Document Object Method

Answer: a

How do you check if a number is NaN in JavaScript?

a. isNaN(number)

b. number.isNaN()

c. isNotANumber(number)

d. typeof(number) === 'nan'

Answer: a

What is the purpose of the textContent property in JavaScript?

a. To set the content of an HTML element

b. To retrieve the content of an HTML element

c. To add a new element to the DOM

d. To create a text node in the DOM

Answer: b

How can you create a new date object representing a specific date in JavaScript?

a. new Date('2023-01-01')

b. new Date(2023, 0, 1)

c. new Date('January 1, 2023')

d. All of the above

Answer: d

How can you include an external JavaScript file in the <head> section of an HTML document?

a. <script src="script.js"></script>
b. <head src="script.js"></head>

c. <link rel="stylesheet" href="script.js">

d. <js src="script.js"></js>

Answer: a

What is the purpose of the break statement in JavaScript?

a. To end the execution of a loop or switch statement

b. To skip the current iteration of a loop

c. To exit a function

d. To display a message box

Answer: a

Which loop executes the code block at least once, even if the condition is false?

a. while

b. for

c. do...while

d. foreach

Answer: c

What is the correct syntax to declare a variable in JavaScript?

a. variable x;

b. x = variable;

c. var x;

d. declare x;

Answer: c

How do you prompt the user for input in JavaScript?

a. input()

b. prompt()
c. getInput()

d. read()

Answer: b

What is the purpose of the confirm dialog box in JavaScript?

a. Display a message box with an OK button

b. Display a prompt for user input

c. Display a confirmation dialog with OK and Cancel buttons

d. Display an alert box

Answer: c

What is the purpose of the onkeyup event in JavaScript?

a. Triggered when a key is pressed

b. Triggered when a key is released

c. Triggered when the mouse is clicked

d. Triggered when the form is submitted

Answer: b

How can you access the first element of an array in JavaScript?

a. array.getFirst()

b. array[0]

c. array.first

d. first(array)

Answer: b

What does the isNaN function in JavaScript check for?

a. If a variable is not a number

b. If a variable is a negative number


c. If a variable is equal to zero

d. If a variable is an integer

Answer: a

In JavaScript, what is the purpose of the this keyword?

a. It refers to the current function

b. It refers to the global object

c. It refers to the object that owns the current function

d. It refers to the next iteration of a loop

Answer: c

What is the purpose of the addEventListener method in JavaScript?

a. To add a new event to an HTML element

b. To listen for a specific event on an HTML element and execute a function

c. To remove an event listener from an HTML element

d. To create a new event handler function

Answer: b

How can you declare a constant variable in JavaScript?

a. constant x = 10;

b. const x = 10;

c. let x = 10;

d. var x = 10;

Answer: b

What is the purpose of the splice method in JavaScript arrays?

a. To add elements to the beginning of an array

b. To remove elements from the middle of an array


c. To reverse the order of elements in an arra

d. To sort the elements of an array

Answer: b

How do you convert a string to uppercase in JavaScript?

a. str.toUpper()

b. str.toUpperCase()

c. toUpperCase(str)

d. convertToUpper(str)

Answer: b

What is the correct way to write a comment that spans multiple lines in JavaScript?

a. /* This is a comment */

b. <!-- This is a comment -->

c. # This is a comment

d. // This is a comment

Answer: a

What is the purpose of the splice method in JavaScript arrays?

a. To add elements to an array

b. To remove elements from an array

c. To reverse the order of elements in an array

d. To sort the elements of an array

Answer: b

How do you round a number to the nearest integer in JavaScript?

a. Math.round(

b. Math.floor()

c. Math.ceil()
d. Math.random()

Answer: a

In JavaScript, what is the purpose of the Object.keys method?

a. To retrieve all keys from an object

b. To add new keys to an object

c. To remove keys from an object

d. To check if a key exists in an object

Answer: a

What is the purpose of the onchange event in JavaScript?

a. Triggered when a key is pressed

b. Triggered when the value of an input changes

c. Triggered when the mouse pointer moves over an element

d. Triggered when a button is clicked

Answer: b

How do you remove the last element from an array in JavaScript?

a. array.delete(0);

b. array.shift();

c. array.remove(0);

d. array.splice(-1, 1);

Answer: b

What is the purpose of the textContent property in JavaScript?

a. To set the content of an HTML element

b. To retrieve the content of an HTML element

c. To add a new element to the DOM

d. To create a text node in the DOM


Answer: b

How do you check if a value is included in an array in JavaScript?

a. array.includes(value)

b. array.contains(value)

c. array.hasValue(value)

d. array.indexOf(value) !== -1

Answer: a

What is the purpose of the localStorage.setItem method in JavaScript?

a. To retrieve an item from local storage

b. To add an item to local storage

c. To remove an item from local storage

d. To clear all items from local storage

Answer: b

How do you convert a string to lowercase in JavaScript?

a. str.toLower()

b. toLowerCase(str)

c. str.toLowerCase()

d. str.lowerCase()

Answer: c

What does the isNaN function in JavaScript check for?

a. If a variable is not a number

b. If a variable is a negative number

c. If a variable is equal to zero

d. If a variable is an integer

Answer: a
In JavaScript, what is the purpose of the this keyword?

a. It refers to the current function

b. It refers to the global object

c. It refers to the object that owns the current function

d. It refers to the next iteration of a loop

Answer: c

What is the purpose of the confirm dialog box in JavaScript?

a. Display a message box with an OK button

b. Display a prompt for user input

c. Display a confirmation dialog with OK and Cancel buttons

d. Display an alert box

Answer: c

How can you include an external JavaScript file in the <head> section of an HTML document?

a. <script src="script.js"></script>

b. <head src="script.js"></head>

c. <link rel="stylesheet" href="script.js">

d. <js src="script.js"></js>

Answer: a

What is the purpose of the addEventListener method in JavaScript?

a. To add a new event to an HTML element

b. To listen for a specific event on an HTML element and execute a function

c. To remove an event listener from an HTML element

d. To create a new event handler function

Answer: b
How do you prompt the user for input in JavaScript?

a. input()

b. prompt()

c. getInput()

d. read()

Answer: b

What is the purpose of the onkeyup event in JavaScript?

a. Triggered when a key is presse

b. Triggered when a key is released

c. Triggered when the mouse is clicked

d. Triggered when the form is submitted

Answer: b

How do you access the first element of an array in JavaScript?

a. array.getFirst()

b. array[0]

c. array.first

d. first(array)

Answer: b

What is the purpose of the textContent property in JavaScript?

a. To set the content of an HTML element

b. To retrieve the content of an HTML element

c. To add a new element to the DOM

d. To create a text node in the DOM

Answer: b
How can you declare a constant variable in JavaScript?

a. constant x = 10;

b. const x = 10;

c. let x = 10;

d. var x = 10;

Answer: b

What is the correct way to write a comment that spans multiple lines in JavaScript?

a. /* This is a comment */

b. <!-- This is a comment -->

c. # This is a comment

d. // This is a comment

Answer: a

What is the purpose of the splice method in JavaScript arrays?

a. To add elements to the beginning of an array

b. To remove elements from the middle of an array

c. To reverse the order of elements in an array

d. To sort the elements of an array

Answer: b

How do you round a number to the nearest integer in JavaScript?

a. Math.round()

b. Math.floor()

c. Math.ceil()

d. Math.trunc()

Answer: a

In JavaScript, what is the purpose of the Object.keys method?


a. To retrieve all keys from an object

b. To add new keys to an object

c. To remove keys from an object

d. To check if a key exists in an object

Answer: a

What is the purpose of the onchange event in JavaScript?

a. Triggered when a key is pressed

b. Triggered when the value of an input changes

c. Triggered when the mouse pointer moves over an element

d. Triggered when a button is clicked

Answer: b

How do you remove the last element from an array in JavaScript?

a. array.delete(0);

b. array.shift();

c. array.remove(0);

d. array.splice(-1, 1);

Answer: b

What is the purpose of the textContent property in JavaScript?

a. To set the content of an HTML element

b. To retrieve the content of an HTML element

c. To add a new element to the DOM

d. To create a text node in the DOM

Answer: b

How do you check if a value is included in an array in JavaScript?


a. array.includes(value)

b. array.contains(value)

c. array.hasValue(value)

d. array.indexOf(value) !== -1

Answer: a

What is the purpose of the localStorage.setItem method in JavaScript?

a. To retrieve an item from local storage

b. To add an item to local storage

c. To remove an item from local storage

d. To clear all items from local storage

Answer: b

How do you convert a string to lowercase in JavaScript?

a. str.toLower()

b. toLowerCase(str)

c. str.toLowerCase()

d. str.lowerCase()

Answer: c

What does the isNaN function in JavaScript check for?

a. If a variable is not a number

b. If a variable is a negative number

c. If a variable is equal to zero

d. If a variable is an integer

Answer: a

In JavaScript, what is the purpose of the this keyword?


a. It refers to the current function

b. It refers to the global object

c. It refers to the object that owns the current function

d. It refers to the next iteration of a loop

Answer: c

What is the purpose of the confirm dialog box in JavaScript?

a. Display a message box with an OK button

b. Display a prompt for user input

c. Display a confirmation dialog with OK and Cancel buttons

d. Display an alert box

Answer: c

How can you include an external JavaScript file in the <head> section of an HTML document?

a. <script src="script.js"></script>

b. <head src="script.js"></head>

c. <link rel="stylesheet" href="script.js">

d. <js src="script.js"></js>

Answer: a

What is the purpose of the addEventListener method in JavaScript?

a. To add a new event to an HTML element

b. To listen for a specific event on an HTML element and execute a function

c. To remove an event listener from an HTML element

d. To create a new event handler function

Answer: b

How do you prompt the user for input in JavaScript?

a. input()
b. prompt()

c. getInput()

d. read()

Answer: b

How do you declare a global variable in JavaScript?

a. var x = 10;

b. let x = 10;

c. const x = 10;

d. global x = 10;

Answer: a

What is the purpose of the typeof operator in JavaScript?

a. To check if a variable is undefine

b. To check the type of a variable

c. To concatenate strings

d. To perform a logical AND operation

Answer: b

Which of the following statements is true about the == operator in JavaScript?

a. It checks both value and type equality.

b. It only checks value equality.

c. It only checks type equality.

d. It is used for assignment.

Answer: b

How do you comment out a single line in JavaScript?

a. /* This is a comment */

b. <!-- This is a comment -->


c. # This is a comment

d. // This is a comment

Answer: d

What is the purpose of the setTimeout function in JavaScript?

a. To set the time of the system clock

b. To execute a function after a specified delay

c. To measure the time taken by a function to execute

d. To create a timer for animations

Answer: b

What does the NaN value represent in JavaScript?

a. Not a Number

b. Null and Negative

c. Non-Applicable Number

d. Numeric Array

Answer: a

How can you prevent the default behavior of an HTML form submission using JavaScript?

a. event.default();

b. event.stop();

c. event.preventDefault();

d. event.halt();

Answer: c

What is the purpose of the innerHTML property in JavaScript?

a. To retrieve the inner text of an element

b. To set the inner content of an element as HTML

c. To check if an element has child elements


d. To add a new element to the DOM

Answer: b

In JavaScript, what is the role of the constructor method in an object?

a. To construct the object and initialize its properties

b. To deconstruct the object and free up memory

c. To check if an object is a constructor

d. To create a copy of the object

Answer: a

What is the purpose of the slice method in JavaScript arrays?

a. To remove elements from an array

b. To create a shallow copy of an array

c. To concatenate two arrays

d. To sort the elements of an array

Answer: b

UNIT 6 MCQ

1. What is JavaScript? a) A style sheet language b) A programming language c) A database


language d) A markup language

Answer: b) A programming language

2. Which of the following is not a JavaScript data type? a) Number b) String c) Boolean
d) Float

Answer: d) Float
3. How do you declare a variable in JavaScript? a) var x; b) x = var; c) variable x; d) x :=

Answer: a) var x;

4. What does the === operator do in JavaScript? a) Checks for equality without type
coercion b) Checks for equality with type coercion c) Assigns a value d) Checks for
inequality without type coercion

Answer: a) Checks for equality without type coercion

5. What is the purpose of the setTimeout function in JavaScript? a) Pauses the execution
of the script b) Sets a delay before executing a function c) Executes a function immediately
d) Sets an interval for executing a function repeatedly

Answer: b) Sets a delay before executing a function

6. Which keyword is used to declare a function in JavaScript? a) func b) function c)


method d) def

Answer: b) function

7. What does the this keyword refer to in JavaScript? a) The current function b) The
global object c) The object that is executing the current function d) The parent function

Answer: c) The object that is executing the current function

8. How do you comment a single line in JavaScript? a) <!-- Comment --> b) /* Comment
*/ c) // Comment d) -- Comment --

Answer: c) // Comment

9. What is the purpose of the parseInt function in JavaScript? a) Converts a string to a


floating-point number b) Converts a string to an integer c) Returns the length of a string d)
Converts a number to a string

Answer: b) Converts a string to an integer

10. Which of the following is a falsy value in JavaScript? a) 0 b) " " c) true d) "hello"

Answer: a) 0
DOM Concepts:
11. What does DOM stand for? a) Document Object Model b) Data Object Model c)
Document Order Model d) Document Offset Model

Answer: a) Document Object Model

12. Which method is used to access an HTML element by its ID in JavaScript? a)


getElementByTag b) getElementById c) getElementByClass d) selectElementById

Answer: b) getElementById

13. How do you create a new HTML element using JavaScript? a) createNode b)
createElement c) newElement d) makeElement

Answer: b) createElement

14. What property is used to change the content of an HTML element in JavaScript? a)
innerText b) contentText c) textContent d) innerHTML

Answer: d) innerHTML

15. How do you add a class to an HTML element using JavaScript? a) addClass b)
appendClass c) addAttribute d) classList.add

Answer: d) classList.add

16. Which method is used to remove a class from an HTML element in JavaScript? a)
removeClass b) deleteClass c) classList.remove d) detachClass

Answer: c) classList.remove

17. What is the purpose of the setAttribute method in JavaScript? a) Sets the style of an
element b) Adds a new attribute to an element c) Removes an attribute from an element d)
Retrieves the value of an attribute

Answer: b) Adds a new attribute to an element

18. Which property is used to change the CSS style of an HTML element in JavaScript?
a) style b) css c) layout d) design

Answer: a) style
19. What does the querySelector method do in JavaScript? a) Selects the first element
that matches a CSS selector b) Selects all elements that match a CSS selector c) Selects the
last element that matches a CSS selector d) Selects elements based on their IDs

Answer: a) Selects the first element that matches a CSS selector

20. Which method is used to add an event listener to an HTML element in JavaScript?
a) addEventListener b) attachEvent c) addEvent d) eventListener

Answer: a) addEventListener

21. What is the purpose of the preventDefault method in an event listener? a) Stops the
event from propagating to parent elements b) Prevents the default action associated with
the event c) Delays the execution of the event handler d) Stops the event from bubbling up
the DOM tree

Answer: b) Prevents the default action associated with the event

22. Which event type is triggered when a user clicks an HTML element? a) click b)
mouseover c) keypress d) submit

Answer: a) click

23. What is event delegation in JavaScript? a) Assigning multiple events to a single


element b) Assigning a single event to multiple elements c) Dynamically adding and
removing event listeners d) Using event listeners with delegation syntax

Answer: b) Assigning a single event to multiple elements

24. What does the stopPropagation method do in an event listener? a) Stops the event
from propagating to parent elements b) Prevents the default action associated with the
event c) Delays the execution of the event handler d) Stops the event from bubbling up the
DOM tree

Answer: a) Stops the event from propagating to parent elements

25. How do you access the target element in an event listener? a) event.element b)
event.target c) event.srcElement d) event.destination

Answer: b) event.target
26. What is the purpose of the typeof operator in JavaScript? a) Returns the type of a
variable or expression b) Checks if a variable is defined c) Converts a variable to a boolean
d) Converts a variable to a string

Answer: a) Returns the type of a variable or expression

27. How do you check if a variable is undefined in JavaScript? a) if (variable ==


undefined) b) if (variable === undefined) c) if (isUndefined(variable)) d) if (typeof variable
=== "undefined")

Answer: d) if (typeof variable === "undefined")

28. What does the NaN value represent in JavaScript? a) Not a Number b) Null and None
c) Negative Absolute Number d) No Assignment

Answer: a) Not a Number

29. Which function is used to convert a string to uppercase in JavaScript? a)


toUpperCase() b) upperCase() c) makeUpperCase() d) convertUpper()

Answer: a) toUpperCase()

30. What is the purpose of the JSON.stringify function in JavaScript? a) Parses a JSON
string b) Converts a JavaScript object to a JSON string c) Converts a JSON string to a
JavaScript object d) Checks if a string is in JSON format

Answer: b) Converts a JavaScript object to a JSON string

DOM Concepts:
31. Which property is used to access the parent node of an element in JavaScript? a)
parentNode b) parentElement c) parent d) parentDiv

Answer: a) parentNode

32. What is the purpose of the appendChild method in JavaScript? a) Appends an element
to the end of the parent's child nodes b) Removes the last child node of an element c)
Creates a new child node for an element d) Appends an element to the beginning of the
parent's child nodes

Answer: a) Appends an element to the end of the parent's child nodes


33. How do you remove an HTML element from the DOM using JavaScript? a)
removeElement() b) deleteElement() c) removeChild() d) deleteChild()

Answer: c) removeChild()

34. What does the innerHTML property do in JavaScript? a) Returns the content of an
element as HTML b) Sets the text content of an element c) Returns the text content of an
element d) Sets the HTML content of an element

Answer: d) Sets the HTML content of an element

35. What is the purpose of the cloneNode method in JavaScript? a) Creates a duplicate of
an element b) Removes a node from the DOM c) Clones the parent node of an element d)
Copies the attributes of an element

Answer: a) Creates a duplicate of an element

36. Which method is used to check if an element has a particular class in JavaScript?
a) hasClass b) containsClass c) includesClass d) classList.contains

Answer: d) classList.contains

37. What is the purpose of the getAttribute method in JavaScript? a) Retrieves the value
of an attribute b) Sets the value of an attribute c) Checks if an attribute exists d) Removes
an attribute from an element

Answer: a) Retrieves the value of an attribute

38. How do you change the source (src) attribute of an image element in JavaScript?
a) image.src = "new-source.jpg"; b) image.changeSrc("new-source.jpg"); c)
image.setAttribute("src", "new-source.jpg"); d) image.updateSource("new-source.jpg");

Answer: c) image.setAttribute("src", "new-source.jpg");

39. What is the purpose of the firstChild property in JavaScript? a) Returns the first
child node of an element b) Returns the last child node of an element c) Returns the parent
node of an element d) Returns the sibling node before an element

Answer: a) Returns the first child node of an element


40. Which method is used to set the focus on an input element in JavaScript? a)
inputElement.focus() b) setFocus(inputElement) c) focusInput(inputElement) d)
inputElement.setFocus()

Answer: a) inputElement.focus()

DOM HTML:
41. How do you create a line break (line break element) in HTML? a) <line> b) <br> c)
<lb> d) <break>

Answer: b) <br>

42. Which HTML element is used to define a hyperlink? a) <link> b) <hyperlink> c) <a>
d) <url>

Answer: c) <a>

43. What is the purpose of the alt attribute in the <img> element in HTML? a) Specifies
the image source b) Defines alternative text for the image c) Sets the image width d)
Specifies the image alignment

Answer: b) Defines alternative text for the image

44. Which HTML element is used to define an unordered list? a) <list> b) <ol> c) <ul>
d) <li>

Answer: c) <ul>

45. How do you create a table in HTML? a) <table> b) <tr> c) <td> d) All of the above

Answer: d) All of the above

DOM CSS:
46. What is the purpose of the display property in CSS? a) Sets the width of an element
b) Defines the type of box an element generates c) Specifies the margin of an element d)
Sets the background color of an element

Answer: b) Defines the type of box an element generates

47. How do you set the font size of an element in CSS? a) font-size b) text-size c) size-
font d) font-style
Answer: a) font-size

48. What does the margin: 10px 20px; CSS rule do? a) Sets the top margin to 10 pixels and
the right margin to 20 pixels b) Sets the margin to 10 pixels for all sides c) Sets the top and
bottom margins to 10 pixels and the left and right margins to 20 pixels d) Sets the margin
to 20 pixels for all sides

Answer: c) Sets the top and bottom margins to 10 pixels and the left and right
margins to 20 pixels

49. How do you center an element horizontally in CSS? a) text-align: center; b) margin:
auto; c) align: center; d) center: true;

Answer: b) margin: auto;

50. What is the purpose of the float property in CSS? a) Sets the alignment of text b)
Clears the floated elements c) Creates a floating element d) Specifies the positioning of an
element

Answer: c) Creates a floating element

DOM Events:
51. Which event type is triggered when a user presses a key on the keyboard? a)
keydown b) keypress c) keyup d) keyboard

Answer: a) keydown

52. What is the purpose of the event.stopPropagation() method in an event listener? a)


Stops the event from propagating to parent elements b) Prevents the default action
associated with the event c) Delays the execution of the event handler d) Stops the event
from bubbling up the DOM tree

Answer: a) Stops the event from propagating to parent elements

53. How do you attach multiple event listeners to the same element in JavaScript? a)
addEventListeners b) addEvent c) addEventListenerAll d) addListener

Answer: a) addEventListeners

54. Which method is used to remove an event listener from an HTML element in
JavaScript? a) removeEvent b) removeEventListener c) deleteEventListener d)
removeListener
Answer: b) removeEventListener

55. What does the mouseover event type do in JavaScript? a) Triggered when the mouse
pointer enters an element b) Triggered when the mouse pointer leaves an element c)
Triggered when a key is pressed d) Triggered when a key is released

Answer: a) Triggered when the mouse pointer enters an element

56. Which event type is triggered when an HTML form is submitted? a) submitForm b)
formSubmit c) submit d) formSubmitted

Answer: c) submit

57. What is the purpose of the event.preventDefault() method in an event listener? a)


Stops the event from propagating to parent elements b) Prevents the default action
associated with the event c) Delays the execution of the event handler d) Stops the event
from bubbling up the DOM tree

Answer: b) Prevents the default action associated with the event

58. Which property is used to access the key that was pressed in a keypress event? a)
key b) keyCode c) charCode d) pressKey

Answer: a) key

59. How do you check if the Ctrl key is pressed in a keyboard event in JavaScript? a)
event.ctrlKey b) event.key === "Ctrl" c) event.isCtrlPressed d) event.hasCtrlKey

Answer: a) event.ctrlKey

60. What does the focus event type do in JavaScript? a) Triggered when an element
gains focus b) Triggered when an element loses focus c) Triggered when a key is pressed d)
Triggered when a key is released

Answer: a) Triggered when an element gains focus

61. What is the purpose of the map function in JavaScript? a) Applies a function to each
element in an array and returns a new array b) Joins two arrays into a single array c)
Removes elements from an array based on a condition d) Finds the maximum value in an
array

Answer: a) Applies a function to each element in an array and returns a new array
62. How do you check if a variable is an array in JavaScript? a) isArray(variable) b)
isTypeOf(variable, "array") c) variable.isArray() d) typeOf(variable) === "array"

Answer: a) isArray(variable)

63. What is the purpose of the filter function in JavaScript? a) Creates a new array
with the results of a provided function b) Removes elements from an array based on a
condition c) Sorts the elements of an array d) Checks if all elements in an array pass a test

Answer: b) Removes elements from an array based on a condition

64. How do you declare a constant variable in JavaScript? a) const x = 10; b) let x = 10;
c) var x = 10; d) constant x = 10;

Answer: a) const x = 10;

65. What is the purpose of the splice method in JavaScript? a) Adds or removes
elements from an array b) Concatenates two arrays c) Reverses the elements of an array d)
Finds the index of a specified element in an array

Answer: a) Adds or removes elements from an array

DOM Concepts:
66. How do you create a text node in the DOM using JavaScript? a) createTextElement
b) newTextElement c) document.createTextNode d) textNode.create

Answer: c) document.createTextNode

67. What does the event.currentTarget property return in an event listener? a) Returns
the target element of the event b) Returns the current element being processed in the event
propagation c) Returns the event type d) Returns the parent element of the event target

Answer: b) Returns the current element being processed in the event propagation

68. How do you check if an element has a specific attribute in JavaScript? a)


element.hasAttribute("attributeName") b) element.containsAttribute("attributeName") c)
element.isAttributePresent("attributeName") d) element.getAttribute("attributeName")
!== null

Answer: a) element.hasAttribute("attributeName")
69. What is the purpose of the classList.toggle method in JavaScript? a) Adds a class to
an element b) Removes a class from an element c) Toggles between adding and removing a
class from an element d) Checks if an element has a specific class

Answer: c) Toggles between adding and removing a class from an element

70. How do you set the value of a form input field using JavaScript? a) inputField.value
= "new value"; b) setInputValue(inputField, "new value"); c) inputField.setValue("new
value"); d) setFormValue("new value", inputField)

Answer: a) inputField.value = "new value";

You might also like