Which layout method causes images to render to small or too large in browser windows of different sizes?
Answer : B
A fixed-width layout method specifies exact pixel values for widths. This approach does not adapt to different screen sizes, leading to images rendering too small or too large on various devices.
Fixed Width Layout:
Definition: Uses specific pixel values for the width of elements.
Example:
.container {
width: 800px;
}
Issues:
Lack of Flexibility: Does not scale with the size of the viewport, causing images and other elements to appear incorrectly sized on different screen sizes.
Comparison:
Fluid/Liquid: Adapts to the screen size using percentages or other relative units.
Relative Width: Also adapts using units like em or %.
MDN Web Docs - Fixed vs. Fluid Layout
W3C CSS Flexible Box Layout Module Level 1
Using fixed-width layouts can result in poor user experience across different devices, highlighting the importance of responsive design principles.
Top of Form
Bottom of Form
Which element attaches an external CSS document to a web page?
Answer : B
To attach an external CSS document to a web page, the <link> element is used within the <head> section of the HTML document.
<link> Element:
Purpose: Links external resources, such as stylesheets, to the HTML document.
Attributes:
rel='stylesheet': Specifies the relationship between the current document and the linked resource.
href='path/to/stylesheet.css': Specifies the URL of the external stylesheet.
Example:
<head>
<link rel='stylesheet' href='styles.css'>
</head>
Other Options:
<style>: Used to embed internal CSS directly within the HTML document, not for linking external CSS.
<script>: Used to embed or link to JavaScript files.
<meta>: Provides metadata about the HTML document, not for linking stylesheets.
W3C HTML5 Specification - The link element
MDN Web Docs - <link>
By using the <link> element correctly, you can ensure that your web page is styled with external CSS, maintaining a separation of concerns and making your HTML more manageable.
Which structure tag should a developer use to place contact information on a web page?
Answer : D
The <footer> tag is used to define a footer for a document or a section. A footer typically contains information about the author of the document, contact information, copyright details, and links to terms of use, privacy policy, etc. It is a semantic element in HTML5, which means it clearly describes its meaning to both the browser and the developer.
Purpose of <footer>: The <footer> element represents a footer for its nearest sectioning content or sectioning root element. It typically contains information like:
Contact information
Copyright information
Links to related documents
Information about the author
Usage Example:
<footer>
Contact us at: contact@example.com
© 2024 Example Company
</footer>
In this example, the <footer> tag encloses contact information and copyright details.
Semantic Importance: Using semantic elements like <footer> enhances the accessibility of the document and provides better context for search engines and other user devices.
MDN Web Docs on <footer>
W3C HTML5 Specification on <footer>
What is the used to render images dynamically?
Answer : B
The <canvas> element in HTML5 is used to render images and graphics dynamically through JavaScript. It is a powerful feature for creating graphics, game visuals, data visualizations, and other graphical content directly in the browser.
Canvas Element: The <canvas> element is an HTML tag that, with the help of JavaScript, can be used to draw and manipulate graphics on the fly.
Usage Example:
<canvas id='myCanvas' width='200' height='100'></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#FF0000';
ctx.fillRect(0, 0, 200, 100);
</script>
In this example, a red rectangle is drawn on a canvas element.
MDN Web Docs on <canvas>
W3C HTML Canvas 2D Context Specification
What is the default behavior of overlay elements?
Answer : A
In CSS, when elements overlap, the default behavior is that the last element listed in the HTML document appears on top.
Stacking Context:
Default Behavior: Elements are stacked in the order they appear in the HTML. The last element in the document tree is rendered on top.
z-index: You can control stacking order using the z-index property, but without it, the default order applies.
Example:
Given HTML:
The blue div will be on top of the red div because it appears later in the HTML document.
MDN Web Docs - Stacking context
W3C CSS Positioned Layout Module Level 3
By understanding these fundamental CSS concepts, developers can create more effective and visually appealing web layouts.
What is the term for a JavaScript function that is defined as part of an object?
Answer : D
> ''A method is a function property of an object. In JavaScript, when a function is assigned as a property of an object, it is called a method of that object.''
>
> Example:
```javascript
const person = {
greet: function() {
return 'Hello!';
}
};
```
> In the above, `greet` is a method of the `person` object.
* MDN Web Docs: Working with Objects -- Methods
* JavaScript Reference: Functions in objects
---
Where can users items using the HTML
Answer : C
Using HTML, users can upload files from their computer to a web page using the <input> element with the type='file' attribute.
File Upload Input: The <input type='file'> element is used in forms to allow users to select files from their local file system to be uploaded to a server.
Usage Example:
The <canvas> element in HTML5 is used to render images and graphics dynamically through JavaScript. It is a powerful feature for creating graphics, game visuals, data visualizations, and other graphical content directly in the browser.
Canvas Element: The <canvas> element is an HTML tag that, with the help of JavaScript, can be used to draw and manipulate graphics on the fly.
Usage Example:
html
Copy code
<canvas id='myCanvas' width='200' height='100'></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#FF0000';
ctx.fillRect(0, 0, 200, 100);
</script>
In this example, a red rectangle is drawn on a canvas element.
MDN Web Docs on <canvas>
W3C HTML Canvas 2D Context Specification
<form action='/upload' method='post' enctype='multipart/form-data'>
<input type='file' name='fileToUpload' id='fileToUpload'>
<input type='submit' value='Upload File' name='submit'>
</form>
In this example, users can choose a file from their computer and upload it to the specified server endpoint.
MDN Web Docs on <input type='file'>
W3C HTML Specification on File Upload