HTML5 Flashcards

1
Q

What is the section tag used for?

A

It is typically used to contain a blob of data. It is usually only used if the data would have a natural heading. The spec says that a section should usually be identified by having a heading (h1-h6) as a child of the section element.

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

What are the two elements used when quoting text?

A

< q> and <blockquote>

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

What is the difference between a block element and an inline element?

A

Block elements are always displayed as if they have a linebreak after them, inline are displayed inline with text.

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

What do you call an element with no content?

A

A void element (br element for example)

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

HTML has ordered and unordered lists - are there any others?

A
yes, definition lists. 
< dl>
  <dt>Definition term</dt>
  <dd>Definition Description</dd>
< /dl>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is nesting?

A

When separate HTML elements are included within each other.

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

Is the img tag a block or inline element?

A

inline block (i.e. it is inline, but has some behaviors of block elements)

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

What role does the h1, h2 etc tags play in SEO?

A

The higher numbers (i.e. h1) have a higher priority in a search engine result - prioritising sections of page based on heading numbers

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

What is SEO?

A

Search Engine Optimisation

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

How do you configure an “a” element to make a link open in a new window?

A

Use the “target” attribute - to make it ALWAYS open in a new window, use the value “_blank”.

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

What is responsive web design?

A

When a web layout automatically conforms to a devices screen / limitations through use of CSS

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

What tag do you use to make sure the web page starts at the right scale for a device?

A

< meta name=”viewport” content=”width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0” />

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

What do you use to ensure IE 7 and 8 can deal with HTML5 tags?

A

HTML5Shiv

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

How do you make your website use a specific CSS style sheet based on device?

A

Use the media attribute on the link tag..

< link rel=”stylesheet” type=”text/css” media=”only screen and (min-width:50px) and (max-width:500px)” href=”css/screen_layout_small.css” />

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

What would be a cause for fonts getting progressively bigger throughout a page?

A

Not closing off h1 (h2 etc) tags. Opening the tag tells the browser to increase the font, closing it tells it to decrease - not closing means it’s additive.

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

What does the canvas tag look like?

A

<canvas></canvas>

17
Q

How do you obtain a 2d context for a canvas?

A
var canv = document.getElementById("canvas");
var context = canv.getContext("2d");
18
Q

How would you fill the background of a canvas with the color blue?

A

(Having obtained a 2d context and a handle to ‘canv’)

context. fillStyle = “blue”;
context. fillRect(0, 0, canv.width, canv.height);

19
Q

What is one significant difference between declaring a function and assigning a function to a variable?

A
If the function is simply declared, the order that it is called (i.e. before it is declared in code) does not matter. However, if it is assigned to a variable, the function is only parsed in the second pass of the compiler - and will therefore cause an error if the function is called before it is declared (via the variable).
foo();
var foo = function() {}
// ERROR!
20
Q

How do you load a sprite?

A
var image = new Image();
// Then set the src attribute
image.src = 'nameoffile.png';
21
Q

How do you draw a sprite?

A

using the context
Game.context.drawImage();
// There are a large number of params for this

22
Q

How do you create a new drawing state?

A

Game.canvasContext.save();

23
Q

How do you remove an existing drawing state?

A

Game.canvasContext.restore();

24
Q

How would you translate a sprite (in a new drawing state)?

A

Game.canvasContext.translate(100, 100);

25
Q

What steps would you use to translate and draw a sprite using draw states?

A

Game.canvasContext.save();
Game.canvasContext.translate();
Game.canvasContext.drawImage();
Game.canvasContext.restore();

26
Q

When passing data as a parameter - what is the syntax for passing a struct like data structure?

A

function_name({ x: 100, y: 200 });

This is an object literal and lets you reference it by..
param_name.x
param_name.y

27
Q

How do you create an audio object to play an mp3 music track?

A
Game.music = new Audio();
Game.music.src = "mymusic.mp3";
28
Q

Given an initialised music clip - how do you play the music?

A

Game.music.play();

29
Q

Given an initialised music clip - how do you change the volume of the music?

A

Game.music.volume(0.4);

from 0 - 1

30
Q

There are two parameters that give position in a mouseMove handler - what are they?

A

pageX and pageY

clientX and clientY

31
Q

What is the difference between pageX and clientX?

A

clientX (parameter passed in a mouseMove handler) doesn’t take into consideration scrolling.

32
Q

What is the difference between Math.atan and Math.atan2 ?

A

Math.atan2 takes two parameters (the adjacent and opposite lengths) and returns and returns the equivalent in radians of 90 degrees). It is useful because the two parameters allow the function to detect whether a value of 0 was passed (not possible with atan) and gives an appropriate value.

33
Q

What steps would you use to translate, ROTATE and draw a sprite using draw states?

A
Game.canvasContext.save();
Game.canvasContext.translate();
Game.canvasContext.rotate();
Game.canvasContext.drawImage();
Game.canvasContext.restore();
34
Q

When you receive an event for a mouse button press, there are three possible values for evt.which. What are they?

A

left button = 1
middle button = 2
right button = 3

35
Q

What is the issue with spreading your classes across multiple files?

A

There is no simple way to enforce loading in order to preserve dependencies. Therefore you need to write a script that will load the files / and wait until it has finished before loading the next one. (such as LABjs)