Chapter 1c - How do I write a script for a web page? Flashcards

1
Q

How HTML CSS and JavaScript fit together

A

Different languages should be kept in separate files

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

HTML is…

A

The content layer
It is where the content of the page lives
It adds page structure and semantics

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

CSS is…

A

The presentation layer

CSS enhances HTML with rules that state how HTML content is presented

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

JavaScript is…

A

The behaviour layer
This is where we can change how a web page behaves.
It adds interactivity
We should keep as much of our JavaScript in separate files as possible

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

Progressive Enhancement is

A

Many aspects of a browsing experience differ
screen size
connection speed
device capability

HTML first
works on all devices

HTML and CSS
separate rules for how the page looks
One fast sheet, or many to create different views of the same data

HTML, CSS and JavaScript
JS added last
Enhances usability / interactivity of the site
Keeping it separate means the site works without JS
JS code can be reused on several pages

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

Javascript is written in…

A

Plain text with a .js file suffix

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

Javascript is added to a page…

A

using the HTML element - this tells the browser it has encountered a script
The script element has a src attribute, the value of which is the path script that was created

Does Javascript alter the source code?

No. The script works with the DOM.

Is it possible to add Javascript directly to a page? Is it recommended?

It is possible, between tags. It is not recommended, as it is best to separate files.

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

Describe how object and methods work, using an example

A

Example - document.write(‘Good afternoon!’);

The document object represent the entire web page
The document has various methods and properties
These are called members of the object
The dot is the member operator.
It joins the object name to the member you want to access.
When a method needs information to work, the data is given within parentheses,
Each bit of information of this type is called a parameter
Above the write() method needs to know what to write

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

When will a browser execute JavaScript?

A

It will execute it when it finds it, stopping to load the script and then checking if anything needs doing.

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