Technologies underlying the web Flashcards

1
Q

What is syntax?

A

The structure of statements in a computer language.

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

Why is there a need to use JavaScript and CSS in the Web 2.0?

A

The Web 2.0’s content (constructed using HTML) has a style/layout (constructed using CSS) as well as a behaviour (controlled using JavaScript).

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

What does the basic structure of an HTML document include?

A
  1. Document type declaration
  2. HTML tags
  3. Head tags
  4. Title tags (usually included in head so it titles the whole window)
  5. Title of the page < h1 > < /h1 > (usually included in body)
  6. Body tags
  7. Paragraph tag < p > < /p > (usually included in body)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you include CSS (as a file) in an HTML document?

A

Included in the head using the following syntax:

< link rel=”stylesheet” type=”text/css” href=”theme.css” >

Note: “theme.css” refers to a hypothetical CSS file.

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

What kind of syntax could be included in a CSS file? (E.g. theme.css)

A

An example element could be:

h1 { color: green; } –> note the American spelling

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

How do you include JavaScript (as a file) in an HTML document?

A

Included in the body using the following syntax:

< script src=”my_script.js” > < / script >

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

How do you call a JavaScript function?

A

Identify the name of the function that was ‘called’/included in the HTML.
E.g. buttons can be specified in an HTML document using the following syntax:

< button type=”button” onclick=”myFunction()” >Date < / button >

In this case, you should state “myFunction();” in the JavaScript to call this function.

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

What kind of syntax is included in a JavaScript file? (E.g. my_script.js)

A
The file would include the following syntax: 
function myFunction() {
document.getElementById("demo").innerHTML = Date();
}

Note: getElementById(“demo”) would refer to an element in the HTML with Id “demo” so for example,
< p id=”demo” > < / p >

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

What are some useful things you can do with JavaScript?

A

JavaScript aids in giving the user more control over the browser. It allows the creation of:

  • pop up alerts
  • interactive attribute change (e.g. turning the bulb on & off)
  • drawing pictures
  • interactive text creation (e.g. commenting on blogs)
  • updating parts of the page without loading the entire page again (e.g. ASOS and quick view)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are some things that should be considered when implementing JavaScript into an HTML document?

A

Different browsers may produce different results:

  • JavaScript could be disabled by some end-users.
  • Some commands only work in Internet Explorer and not other browsers.
  • Versions of browsers matters.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are variables?

A
  • Must be declared by the word var (e.g. var age = 42;) Also, 42 refers to the value which has been assigned to the variable.
  • An example variable: a name might be a variable which takes the value “Frank”. BUT “Frank” is not the same variable as Name.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are some different types of variables?

A
  • number
  • string
  • boolean
  • object
  • null
  • undefined (nothing has been assigned)
  • NaN (e.g. dividing by 0)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are some examples of pre-defined functions in JavaScript?

A
  • pop up alerts (window will appear with your message to the end user of the website)
  • date (always gets current date)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How is a function defined in JavaScript?

A
  1. Need the keyword ‘function’ to start defining.
  2. A name for your choice for the function (e.g. showAge)
  3. Open and close parenthesis after function name ()
  4. Curly brackets {and} enclose all statements to execute as part of function.
  5. All statements should end with a semi-colon ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Give an example of a defined function in JavaScript.

A
var age=42;
function showAge() {
alert("You are" + age); 
age= 65;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does a defined function essentially do?

A

Illustrates a set of commands to say how the function will operate when the function is called.
E.g. similar to the way a microwave’s function is defined in the specifications, it does not operate until the ‘start’ button is pushed so calling a function is the equivalent to pushing the ‘start’ button.

17
Q

What are the fundamental characteristics of HTML?

A
  • A markup language that defines how the content is organised (i.e. concerned with display) SO the purpose isn’t defined.
  • Contains predefined set of tags, attributes and values.
  • Constructed upon a predefined basic structure.
  • Lenient syntax (e.g. not case sensitive, ignores extra space, some tags don’t need closed, forgives many human errors).
18
Q

What needs does XML aim to fulfil?

A

Needs are born of the desire to make markup language more compatible across different applications/services, concentrating on structured representation of knowledge, so to achieve this there is a need for:

  • Flexible extensible tags, attributes and values for different services.
  • Embed/fixed ‘meaning’ to describe what the object is i.e. becoming self-descriptive for different applications.
  • Structure to be defined by administrator to serve a specific purpose.
  • Stricter syntax to allow exchange across applications and communities (e.g. case sensitive, extra space acknowledged, tags must be opened and closed, tags nested in right order, unforgiving of human errors).
19
Q

What does the basic structure of an XML document include?

A
  1. Declaration of document type, version and encoding:
    < ?xml version=”1.0” encoding=”UTF-8”? >

The building blocks of XML are referred to as elements. An element consists of:

  1. Opening tag (e.g. < child > ) i.e. the root
  2. Closing tag (e.g. < / child >)
  3. Content (anything included within the opening and closing tags) –> first tag included of content = child of root, then sub child etc.
  4. Attribute(s) associated with the element (e.g. included in the opening tag could be < child name=”susie”> )
  5. Value(s) of the attribute(s) (e.g. in this case “susie”)
20
Q

Give an example of an XML element which highlights that structure is determined by administrator.

A

Structure invented for context of “furniture”:

< table >
     < name >African Coffee Table< / name >
     < width >80< / width >
     < length >120< / length >
< / table >

In this case, a table is characterised by name, width and length. However, it doesn’t tell use if a height field can be included to conform to a table.

To make clear the rules for a table to a machine, a definition of a table has to be provided. This can be achieved with a DTD (document type definition) or an XML Schema.

21
Q

How is an attribute defined in XML syntax?

A

Values of attributes are assigned using an equal sign followed by value which must be in quotation marks (e.g. name=”Susie”)

22
Q

What are the rules associated with nesting in XML syntax?

A
  • Elements respect hierarchy. (E.g. if you open a tag within the parent tags it mist be closed before the parents tag is closed):
< root >
< child name=”susie” >
< subchild >
...
< / subchild >
< / child >
< / root >

Elements must be nested properly.

23
Q

What does it mean for an XML document to be well-formed and valid?

A
  • The document confirms to all the syntax rules = well formed.
  • Conforms to the structure specified by either a 1) Document Type Definition (DTD) or 2) XML Schema = valid.