Fundamentals of Front End Development MCQs with Answers
Practice important Fundamentals of Front End Development MCQs with answers and explanations.
Chapter: 130
Q1481:
Fill in the blank: Always use the _______ attribute with images to improve accessibility and prevent broken images.
A. alt
B. title
C. class
D. src
Correct Answer:
A
Chapter: 130
Q1482:
What is the correct way to define image size in HTML5?
A. <img src="html5.gif" alt="HTML5" width:128px height:128px>
B. <img src="html5.gif" alt="HTML5" style="width:128px;height:128px">
C. <img src="html5.gif" alt="HTML5" width="128" height="128">
D. <img src="html5.gif" alt="HTML5" size="128x128">
Correct Answer:
B
Chapter: 130
Q1483:
Fill in the blank: For readability, it is recommended to add _______ spaces of indentation in HTML5.
A. 1
B. 2
C. 4
D. 8
Correct Answer:
B
Chapter: 130
Q1484:
Which of the following tags can be omitted in HTML5?
A. <html>
B. <head>
C. <body>
D. All of the above
Correct Answer:
D
Chapter: 130
Q1485:
What is the recommended way to load an external stylesheet in HTML5?
A. <link rel="stylesheet" href="styles.css" type="text/css">
B. <link href="styles.css" rel="stylesheet">
C. <link rel="stylesheet" href="styles.css">
D. <link rel="stylesheet" href="styles.css" media="all">
Correct Answer:
C
Chapter: 130
Q1486:
Fill in the blank: In HTML5, the <title> element is _______.
A. optional
B. required
C. deprecated
D. only needed for SEO
Correct Answer:
B
Chapter: 130
Q1487:
Which of the following is NOT a recommended practice in HTML5 coding conventions?
A. Use lowercase file names
B. Avoid long code lines
C. Use uppercase attribute names
D. Close all HTML elements
Correct Answer:
C
Chapter: 130
Q1488:
Fill in the blank: HTML comments that span multiple lines should have _______ at the beginning and end.
A. <!-- and -->
B. <-- and -->
C. <!-- and -!>
D. <-- and -->
Correct Answer:
A
Chapter: 130
Q1489:
What is the purpose of using the alt attribute in an img tag in HTML5?
A. To define the image's size
B. To provide an alternative text description
C. To add a caption to the image
D. To specify the file path of the image
Correct Answer:
B
Chapter: 130
Q1490:
Fill in the blank: HTML5 allows the omission of the _______ and _______ tags for simplicity.
A. <html>, <body>
B. <title>, <meta>
C. <head>, <body>
D. <link>, <style>
Correct Answer:
A
Chapter: 130
Q1491:
Which of the following is a best practice for file names in HTML5?
A. Use mixed case file names
B. Use lowercase file names
C. Use uppercase file names
D. Use camelCase file names
Correct Answer:
B
Chapter: 130
Q1492:
What is the best practice for adding metadata in HTML5?
A. Add metadata in the body tag
B. Add metadata in the head tag
C. Metadata is optional
D. Metadata should be added after the body tag
Correct Answer:
B
Chapter: 131
Q1493:
What is the purpose of the HTML <canvas> element?
A. To create forms
B. To draw graphics
C. To insert images
D. To style text
Correct Answer:
B
Chapter: 131
Q1494:
Fill in the blank: The <canvas> element is used to draw graphics on the fly via _______.
A. CSS
B. HTML
C. JavaScript
D. PHP
Correct Answer:
C
Chapter: 131
Q1495:
Which attribute is necessary to reference a canvas element in a script?
A. name
B. class
C. id
D. data
Correct Answer:
C
Chapter: 131
Q1496:
Fill in the blank: The size of the canvas is defined using the _______ and _______ attributes.
A. width, height
B. style, size
C. length, breadth
D. scale, size
Correct Answer:
A
Chapter: 131
Q1497:
What method is used to get the drawing context of a canvas?
A. getContext("3d")
B. getContext("2d")
C. getContext("drawing")
D. getContext("canvas")
Correct Answer:
B
Chapter: 131
Q1498:
Which of the following is the correct method to draw a filled rectangle on a canvas?
A. drawRect(x,y,width,height)
B. fillRectangle(x,y,width,height)
C. fillRect(x,y,width,height)
D. drawFilledRect(x,y,width,height)
Correct Answer:
C
Chapter: 131
Q1499:
Fill in the blank: The _______ method is used to fill a rectangle with color on the canvas.
A. strokeRect()
B. fillStyle()
C. fillRect()
D. drawRect()
Correct Answer:
C
Chapter: 131
Q1500:
What value does ctx.fillStyle represent in the given code: ctx.fillStyle = "#FF0000";
A. Border color
B. Background color
C. Text color
D. Fill color
Correct Answer:
D