50 multiple-choice questions with answers and detailed explanations. Untimed — choose an answer to check it instantly.
0/50 answered0 correct
Question 1 of 50
When using JavaScript, which method would be most appropriate for displaying a message box that does not require user input and only needs acknowledgment?
Correct answer: B) alert()
Explanation: The alert() method displays a message box that the user can close by clicking OK, ideal for simple notifications.
Question 2 of 50
What CSS3 property allows developers to define the distance of an element’s shadow from the element horizontally?
Correct answer: B) h-shadow
Explanation: The h-shadow value sets the horizontal position of the shadow, often called the x-offset.
Question 3 of 50
Which HTML5 input attribute is used to set a limit on the maximum number of characters a user can enter?
Correct answer: D) maxlength
Explanation: The maxlength attribute restricts the input length, ensuring it does not exceed a specified number of characters.
Question 4 of 50
A developer needs to make the background image of a webpage extend only within the padding area of the element. Which background-clip value should they use?
Correct answer: C) padding-box
Explanation: The padding-box value confines the background image within the padding area, stopping at the element’s border.
Question 5 of 50
Which attribute should be added to the <audio> element to ensure it loops continuously?
Correct answer: C) loop="loop"
Explanation: The loop attribute enables continuous playback of an audio file, repeating automatically once it ends.
Question 6 of 50
What is the primary purpose of the @media rule in CSS?
Correct answer: B) To apply styles based on device characteristics
Explanation: The @media rule targets specific device properties (like screen size) to apply responsive styles.
Question 7 of 50
If a developer wants to add multiple styles for an element that only show on hover, which CSS pseudo-class should they use?
Correct answer: C) :hover
Explanation: The :hover pseudo-class applies styles to an element when the user places their cursor over it.
Question 8 of 50
Which JavaScript object can be used to set up a pop-up confirmation box for the user to accept or cancel an action?
Correct answer: C) confirm()
Explanation: The confirm() method creates a pop-up with OK and Cancel options, often used for action confirmation.
Question 9 of 50
When a developer uses the CSS display: none property, what effect does it have on the specified element?
Correct answer: B) Completely removes the element from the layout
Explanation: display: none removes an element from the document flow, as if it were not present.
Question 10 of 50
Which CSS property is used to change the way an element reacts to the z-index and stack order?
Correct answer: D) float
Explanation: The position property affects an element’s stacking context, especially with values like absolute and relative.
Question 11 of 50
In JavaScript, what will the following statement return? typeof "Hello"
Correct answer: A) "string"
Explanation: The typeof operator returns "string" for any string data type.
Question 12 of 50
Which CSS3 property is used to add a configurable shadow to an element’s box?
Correct answer: B) box-shadow
Explanation: box-shadow applies a shadow effect around the border of a box, allowing adjustments for color, blur, and offset.
Question 13 of 50
To display a context menu or tooltip only when an element is right-clicked, which HTML event attribute should be used?
Correct answer: C) oncontextmenu
Explanation: The oncontextmenu event opens a context menu when the user right-clicks on an element.
Question 14 of 50
Which CSS property would you use to add space around an element’s border?
Correct answer: A) margin
Explanation: The margin property adds space around an element’s outer border, separating it from adjacent elements.
Question 15 of 50
What is the purpose of the z-index property in CSS?
Correct answer: B) To control the stacking order of positioned elements
Explanation: The z-index property determines the stack order of overlapping elements, with higher values displaying in front.
Question 16 of 50
Which HTML5 element should be used to define a section containing an advertisement that is separate from the main content?
Correct answer: C) <aside>
Explanation: The <aside> element is used for content that is tangentially related to the main content, like ads or side notes.
Question 17 of 50
A developer is using CSS to position an element at the bottom of its container, and they want it to stay there when the page is scrolled. Which position value should they use?
Correct answer: B) fixed
Explanation: The fixed position keeps the element in place relative to the viewport, unaffected by scrolling.
Question 18 of 50
In JavaScript, which object represents the structure of a webpage, allowing elements to be accessed and manipulated?
Correct answer: B) DOM
Explanation: The DOM (Document Object Model) provides a structured representation of a webpage, allowing dynamic access and manipulation.
Question 19 of 50
Which attribute of the <input> element in HTML5 allows users to select a range of numbers using a slider control?
Correct answer: A) range
Explanation: The range input type enables a slider control, allowing users to select a numerical value within a specified range.
Question 20 of 50
Which JavaScript function returns the length of a string?
Correct answer: C) .length
Explanation: The .length property provides the number of characters in a string.
Question 21 of 50
Which HTML5 element is used to enclose interactive controls like forms or buttons at the top of a web page?
Correct answer: B) <header>
Explanation: The <header> element typically contains introductory content or interactive controls relevant to the page’s main theme.
Question 22 of 50
If a developer wants to play a video from the beginning as soon as the webpage loads, which attribute should be included in the <video> tag?
Correct answer: B) autoplay
Explanation: The autoplay attribute starts the video immediately upon loading without requiring user action.
Question 23 of 50
Which CSS property is used to ensure text that overflows its container is visually managed with ellipses or other effects?
Correct answer: B) text-overflow
Explanation: The text-overflow property manages how text is visually displayed when it exceeds container boundaries, often with ellipses.
Question 24 of 50
When specifying a custom font using the CSS @font-face rule, which properties are required?
Correct answer: B) font-weight and src
Explanation: The @font-face rule requires font-family to name the font and src to specify the font file location.
Question 25 of 50
Which HTML5 input attribute would be used to provide a pattern for validating a US phone number format?
Correct answer: B) pattern
Explanation: The pattern attribute uses regular expressions to validate input formats, like phone numbers, directly in the form field.
Question 26 of 50
Which CSS3 selector targets the last occurrence of an element within its parent container?
Correct answer: B) :last-child
Explanation: The :last-child selector applies styles to the last element of its type within a parent container.
Question 27 of 50
What is the purpose of the defer attribute in the <script> tag?
Correct answer: B) To run the script as soon as possible
Explanation: The defer attribute defers script execution until the HTML document has been fully parsed, optimizing load time.
Question 28 of 50
In CSS, how can a developer center an element horizontally within a container?
Correct answer: B) Use float: center
Explanation: Setting margin: 0 auto centers a block-level element within its container horizontally.
Question 29 of 50
Which HTML5 element is used to display the results of a calculation?
Correct answer: B) <form>
Explanation: The <output> element is designed to display results from calculations or other processing tasks.
Question 30 of 50
Which CSS property sets the background of an element to only cover the content, excluding padding and border?
Correct answer: B) border-box
Explanation: The content-box setting confines the background strictly to the content area, excluding padding and borders.
Question 31 of 50
In JavaScript, which method is used to retrieve a periodic update about the user's current geographic location?
Correct answer: C) watchPosition()
Explanation: The watchPosition() method continually monitors the user’s location and provides periodic updates.
Question 32 of 50
What CSS property specifies whether an element should be hidden or visible, without affecting the layout of the page?
Correct answer: C) visibility
Explanation: The visibility property can hide an element while retaining its space in the layout, unlike display: none, which removes it.
Question 33 of 50
Which HTML5 type allows users to select a value using a calendar picker?
Correct answer: A) date
Explanation: The date input type provides a calendar picker for selecting dates without time zones.
Question 34 of 50
What is the purpose of the CSS overflow property?
Correct answer: A) To control how content overflows its container
Explanation: The overflow property determines how to handle content that exceeds the container’s defined size, offering options like scroll and hidden.
Question 35 of 50
In HTML5, which attribute should be used to define a default value for an element?
Correct answer: B) value
Explanation: The value attribute sets a default value for an element, which is displayed unless the user changes it.
Question 36 of 50
Which JavaScript event occurs when a user removes the input focus from a form field?
Correct answer: A) blur
Explanation: The blur event triggers when an element loses focus, commonly used for form validation.
Question 37 of 50
What is the purpose of the CSS font-family property?
Correct answer: C) To specify the typeface for an element
Explanation: The font-family property assigns a font type or sequence of fallback fonts to text elements.
Question 38 of 50
Which HTML5 input type allows users to select a number by typing or by using up and down arrows?
Correct answer: B) number
Explanation: The number input type allows users to input numbers directly or increment/decrement them with up and down controls.
Question 39 of 50
To make an image draggable in HTML5, which attribute should be set to "true"?
Correct answer: B) draggable
Explanation: Setting draggable="true" on an element makes it draggable within the page.
Question 40 of 50
Which CSS property would you use to specify that an element's content should not exceed the boundaries of the element's box?
Correct answer: B) overflow
Explanation: The overflow property manages content that exceeds the element’s box boundaries, using options like scroll or hidden.
Question 41 of 50
In JavaScript, which operator checks for both value and type equality between two expressions?
Correct answer: C) ===
Explanation: The strict equality operator === checks that both operands have the same value and type.
Question 42 of 50
Which CSS3 property allows text to break and wrap within a container without adding a hyphen?
Correct answer: B) word-wrap
Explanation: The word-wrap property allows long words to wrap to the next line without hyphenation, preventing overflow.
Question 43 of 50
Which HTML5 API is used for controlling and modifying a web page's browsing history?
Correct answer: D) File API
Explanation: The History API provides methods for manipulating the browser’s history, like navigating between pages without reloading.
Question 44 of 50
When using the <form> element, which HTML5 attribute specifies the server endpoint where form data should be sent?
Correct answer: C) action
Explanation: The action attribute in a form specifies the URL where form data should be submitted.
Question 45 of 50
In HTML5, which attribute is used to disable input validation for a form before submission?
Correct answer: A) novalidate
Explanation: The novalidate attribute prevents HTML5 validation for a form upon submission.
Question 46 of 50
A developer wants to use a CSS class to apply floating behavior to an image. Which property would be most useful?
Correct answer: A) float
Explanation: The float property allows elements to wrap around the image, controlling its placement in the layout.
Question 47 of 50
Which CSS3 @rule is used to define custom fonts for a website?
Correct answer: C) @font-face
Explanation: The @font-face rule defines custom fonts for web use, specifying font files and their sources.
Question 48 of 50
What type of variable in JavaScript holds a value of either true or false?
Correct answer: D) Boolean
Explanation: A Boolean variable represents a binary value, either true or false, useful for logical operations.
Question 49 of 50
In CSS3, which property allows an element to appear visible or invisible based on the user’s viewpoint in 3D space?
Correct answer: B) backface-visibility
Explanation: backface-visibility controls whether the back of a transformed 3D element is visible or hidden.
Question 50 of 50
Which JavaScript event occurs when the user modifies the value in a form field?
Correct answer: C) change
Explanation: The change event triggers when the value of a form field is modified, commonly used for input tracking.
Set 2 complete
You scored 0%
0 correct out of 0 answered (50 questions in this set).