HTML Unit 3: Images and Tables Flashcards

1
Q

What is the purpose of the <img> tag in HTML?
Write an example of an <img> tag that includes its required attributes.

A

The <img> tag is used to embed an image in a web page. It creates a holding space for the referenced image, which is linked rather than inserted directly.

<img src="path/to/image.jpg" alt="Description of the image">

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the significance of the <img> tag being an empty tag?

A

The <img> tag is an empty tag because it does not have a closing tag. It contains only attributes to define the image source and alternative text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the src attribute do?

A

Load the image from a specified URL. When a web page loads, it is the browser, at that moment, that gets the image from a web server and inserts it into the page. Therefore, make sure that the image actually stays in the same spot in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon and the alt text are shown if the browser cannot find the image.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why is it important to provide a descriptive value for the alt attribute?

A

Providing a descriptive value for the alt attribute improves accessibility by helping screen readers convey the content of the image to users with visual impairments. It also provides context if the image cannot be loaded.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How should you handle the alt attribute for purely decorative images?

A

For purely decorative images that do not add meaningful content, you can use an empty alt attribute:

<img src="decorative-pattern.jpg" alt="">
This tells screen readers to ignore the image.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you specify the width and height of an image?

A

<img src="img_girl.jpg" alt="Girl in a jacket" style="width:500px;height:600px;">

<img src="img_girl.jpg" alt="Girl in a jacket" width="500" height="600">

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is it recommended to use the style attribute for specifying image dimensions in HTML?

A

Using the style attribute for image dimensions prevents stylesheets from overriding the size of images, ensuring more consistent rendering.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What would happen in the following example if the external CSS rule sets width: 100% for images?

<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">

A

The image’s width would be overridden by the external CSS rule and resized to 100% of its container’s width.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Provide an example of referencing an image stored in a folder named “assets” in your project.

A

<img src="/assets/image.png" alt="Example Image" style="width:150px;height:150px;">

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you reference an image from another server or website?

A

To reference an image from another server, use an absolute URL in the src attribute. You must have permission to use external images, as they might be under copyright. Using images without permission can violate copyright laws. Take note that the link to the external image might change or break.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you use an image as a hyperlink in HTML?

A

To use an image as a link, place the <img></img> tag inside an <a> tag:</a>

<a href="default.asp"> <img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;"> </a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you make an image float to the right of the text using CSS?

A

Use the float property in the style attribute:

<p><img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;"> The image will float to the right of the text.</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the CSS float property do when applied to an image?

A

The float property allows the image to float to the left or right of the surrounding text, causing the text to wrap around the image.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What should you be cautious about when using floating images?

A

When using floating images, be mindful of layout issues, as excessive use of floats can cause overlapping content or disrupt the page’s flow. It’s also important to clear floats when necessary. Clearing floats using style="clear:both;" causes any next elements to be entirely below any (left and right) floating images.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the “clearfix hack”, and when is it used?

A

having a clearfix class, setting
.clearfix::after { content: ""; clear: both; display: table; }

And then assigning this class to any container containing floating images, automatically handles clearing floats, and makes sure elements ‘flow around floats’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are common and supported image formats?

A

.gif, .png, .jpg/.jpeg/.jfif/.pjpeg/.pjp, .ico/.cur, .svg, .apng

15
Q

What is an image map?

A

An image map is an image with clickable areas. These areas are defined using the following HTML:

`<map name="workmap">

<area></area>

<area></area>

<area></area>

</map>`

and then using the usemap attribute with a hashtag for map ID:

<img src="workplace.jpg" alt="Workplace" usemap="#workmap">

16
Q

How to define a rectangular clickable area in an image?

A

<area shape="rect" coords"34, 44, 270, 350" href="computer.htm">

In which the first two coordinates are the top left corner, 34 pixels from the left margin and 44 pixels from the top, and the last two coordinates being the bottom right corner, 270 pixels from the left and 350 from the top.

17
Q

How to define a circular clickable area in an image?

A

<area shape="circle" coords"337,300,44" href="coffee.htm">

In which the first two coordinates are the center of the circle, and the last coordinate is the radius, here 44 pixels.

18
Q

How to have an image map activate a javascript function?

A

Add an onclick event to a corresponding function in javascript.
`<map name=" ">

<area></area>

</map>

<script>
function myFunction() {
alert("You clicked this!");
}
</script>

`

19
Q

How to define a polygonal clickable area in an image?

A

<area shape="poly" coords"140,121,181,116,204,160,204,222,191,270,140,329,85,355,58,352,37,322,40,259,103,161,128,147" href="croissant.htm">

In which the coordinates are pairs of points, together forming a 2D polygon. All coordinates remain X distance from left, then Y distance from top.

20
Q

How to use an image as background?

A

using the CSS
background-image: url('background.jpg');

Setting this to the body element will set a background for the entire page.

21
Q

How can you use a small image as a background?

A

The image will endlessly repeat, but setting
background-repeat: no-repeat; will only give you one tiny image.
Adding
background-attachment: fixed; background-size: cover;
makes the image a stable and page-filling background.

22
Q

What is the difference between “cover” and “100% 100%” when it comes to backgrounds?

A

cover makes sure the image covers the element, but doesn’t stretch.
background-size: 100% 100%; always stretches to fit the element, upon resizing the video, zooming, etc.

23
Q

What do you need <picture> for?

A

to select an image from multiple <source> tags, based on the current view and/or device. Always end with a simple <img> for browsers that do not support any of the <source>s, or do not support the <picture> element.

24
Q

how should you design a <picture> with multiple options?

A

`<picture></picture>

<source></source>

<source></source>

<img src=”imgbase.jpg>
</picture>`

25
Q

What are the two main reasons to use <picture>?

A

Bandwidth: it is not necessary to load large images on small devices.
Format support: some browsers or devices may not support all images. Having <source> tags simply of different image formats can be useful.

26
Q

What is a favicon, and how do you add it?

A

A favicon is a small, high contrast image, that appears next to the html title in the tab.
it is added in the <head>, using:
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">

27
Q

What is the title of your html page?

A

The page title describes the content and meaning of the page, and is added using
<title>My Title</title>

it is essential for SEO (Search Engine Optimisation), and defines the title:
- in the browser toolbar,
- default when added as favourite,
- in the search engine results.

28
Q

What tags give the base structure of a table in HTML?

A

Table, table row, table header and table data.
`<table>

<tr>
<th></th>
<th></th>
<th></th>
</tr>

<tr>
<td></td>
<td></td>
<td></td>
</tr>

</table>`

29
Q

How to change the table border?

A

table, th, td { border: 1px solid black; } gives double borders.

use
`border-collapse: collapse;’
to make those a single grid-like border.

30
Q

Which table element is not given a border?

A

tr, table row

31
Q

How to create an invisible table border?

A

table, th, td{ border: 1px solid white; border-collapse: collapse; } th, td{ background-color: #808080; }

32
Q

How to create round table borders?

A

table, th, td { border: 1px solid black; border-radius: 10px; }

Remember, if you use table padding, the border-radius on the table is the td radius plus padding. With 5px padding, set table to border-radius: 15px.

33
Q

What border-style values are there?

A

dotted, dashed, solid, double, groove, ridge, inset, outset
(none, hidden)

34
Q

What is the use of the border-color property?

A

It can contain four values, and make cells unique colors. Always declare border-style first, or there is nothing to change.

35
Q

what three properties are included in the border shorthand property?

A

border-width, border-style, border-color.

36
Q
A