Prework Study Guide
✨ Open the Console to See What's Happening ✨
HTML
- The head element contains information about the webpage
-
Meta elements written in the head contain meta data - information
about the other information for the browser
-
Elements inside other elments are said to be 'nested'. Child
elements are nested inside parent elements
-
Attributes provide extra infromation for the element. They are
written inside the opening element.
- There is one h1 element on each page. (The main header)
-
The body element acts as a container for all the visible information
on the page (what the user sees)
-
Content is written between an opening tag and closing tag, in the
body.
-
A title element appears in the tab, at the top of the page and
provides important information for SEO
-
An element includes everything inside the angle brackets of the
opening tag to the closing tag
- A tag is only what is inside the angle brackets
CSS
-
A margin indicates how much space we want around the outside of an
element.
-
A padding indicates how much space we want around the content inside
an element.
-
A border indicates how much space we want between the margin and
padding
-
Three ways to write css: Inline - in the attribute of an element,
Internal - using the style tag, inside the head element, External
-In a seperate .css file, with a link to the html file
-
A declaration block is multiple declarations that are written
between curly brackets, and apply to the same selector
- A declaration is a property:value pair
-
A selector is the element that the property: value should target.eg.
h1
-
A property is the characteristic of an element you want to change,
eg. colour
- A value is how you want to change a property eg. blue
-
Add a class to a HTML element attribute to target multiple elements
- Add an id to a HTML element to target a single element
-
Dry (Do not repeat yourself is important), so if you're writting the
same value many times, you can list properties.
Git
- git status: checks what branch we are currently on
-
git checkout -b branch/name: creates a new branch and switches to it
- git add -A: commits all files to the working branch
-
git commit -m "message goes here": Completes the commit command with
a short descriptive message, of what the change ot code is. -m:
stands for message
- git pull origin main - pulls the latest version of the main branch
- git push origin branch/name - pushes the changes to the main branch
JavaScript
-
A variable is a named container that allows us to store data in our
code.
-
Control flow is the order in which a computer executes code in a
script.
-
The best way to write JS is in an external file and linking it in
the footer of the HTML page, under the footer or main closing
element but above the body closing emlement
-
JavaScript code can be written as data types such as string, numbers
or booleans.
-
A string is written between quotation marks: ""HTML, CSS, Git,
JavaScript""
-
These data types can be stored as variables: var topics = "HTML,
CSS, Git, JavaScript"
-
Variables can be accessed passing the variable name to a function
eg. console.log(topics)
-
The order that JavaScript code is executed can be controlled with
conditional statement.
-
One example of a conditional statement is an "if statement". If a
certain condition is met - one set of instructions is carried out.
If not, another set is executed.
-
=== is a strict equality operator. it comparesthe left side to the
right side to see if they're the same.
-
Another way of storing data is in an array. Meant for storing
a list of data, each separated by a comma. These can be strings,
numbers, boolean which are written between [] (open brackets).
- arrayName =['string', number, boolean]
-
These are then stored with a name, and can be accessed by the index
position, starting from 0. arrayName[0] would access the first data
value of an array.
-
arrayName[0], gives the value in first index postion of array.
-
A for loop can iterate over an array and print out every position.
-
A for loop is needs a for keyword, at the start, a conditional
statement (see next list-item), and a code block( so the computer
knows what to do on each iteration).
-
A for loop's conditional statement needs a starting point (a
variable, x=0), a condition (so it knows when to end, x <
arrayName.length), and a predictable pattern to know how to iterate
eg. +1.
-
A shorthand for x = x + 1 is x++. For every iteration, x increases by
1
- arrayname.length gives the number of indices in the array.
-
A function is an easy way to reuse a block of code. The function
must have a keyword "function", before the name of the function,
followed by parentheses. After this, the code is written between {}
(curly brackets).
-
To call a function, write the function name followed by (). Now all
the code in the block will be executed.