Prework Study Guide
✨ Open the Console to See What's Happening ✨
HTML
- The head element contains information about the webpage
- The body element represents the visible content shown to the user
- When working with visible HTML elements, you must always use opening and closing tags
- Child elements are nestled inside other elements
- Parent elements hold the child elements
- Semantic elements have a name that describes its content and role, which makes code easier to read
- A header appears at the top and usually contains a navigation menu and/or introductory content
- When using headings, its important to use in order from h1 to h6. The biggest heading, h1, should only appear once
- A footer goes at the bottom, usually contains the author, copyright, contact, sitemap and navigation
- A section, is a semantic element that defines sections in a document and allows organization of content based on topics
- h1-h6 defines level of heading
- p defines a paragraph or block of text
- ul defines an unordered list (bullets)
- ol defines an ordered list (numbered)
- li defines list items
- img defines information about images, src attribute defines location of image
- br defines a line of empty space, line break between two blocks of content
- a is for anchor, creates links. href attribute points to URL for link
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
- Inline style sheet: styles apply directly to specific element, good for quick and permanent changes, less flexible since each inline style must be edited when making changes
- Internal style sheet: embeded directly into HTML file, style element in head element, rules apply only to that page, single change to CSS rule will apply to all tagged elements
- External style sheet: most common, can keep all CSS rules in separate file, making changes easier. Link file using link element in HTMLs head element
- rel= defines relationship between style sheet and html
- Separation of concerns: separating code into different files based on use. Each section of code should have its own responsibility
- CSS rule is structured with a selector and declaration block, declaration block has declarations made of properties and their values
- A selector defines elements or attributes to which rules/declarations apply
- A * selector indicates that all elements on a page will have the same style properties
- You can combine two selectors with a comma, allowing declaration to affect both selectors, such as header, footer
- DRY code: Do Not Reapeat Yourself code, 2 or more elements that will share the same styling can be grouped together. This reduces the number of lines of code and size and complexity
- text-align: postion property, a way to centre title/heading, can also apply to images
- display:block : assigns each image to start on a new line
- class attribute as selector, adds styles to certain elements of choice, but not all.
- colours can be added by semantic references or hexadecimal code, or hex#
Git
- git status: checks what branch we are currently on
- git checkout -b branch-name: creates a new branch and switches to it
- git checkout main: takes you back to main branch
- git add -A: adds modification in current working branch to staging area. -A indicates we want to add all changes
- staging area informs Git that the changes will be added in next commit
- git commit -m: commit command with message that describes what commit contains
- git pull: receive a branch's modifications into local environment
- git pull origin: the source pull will be from the GitHub repo
- git pull origin main: indicates main branch will be pulled from GitHub repo
- git push: pushes changes from local environment to remote GitHub
- git push origin feature/branch-name: pushes changes we have locally to remote Github branch in repo, or creates new 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.
- Code is read and executed from top to bottom of page
- To declare a variable use var, give it a unique name, then assign operator = to assign specific data we want to store.
- console.log method is used to output a message to the web console by adding an argument.
- console refers to a test environment that developers use to check code.
- .log is a method, a set of instructions to be executed.
- if statement can interrput the control flow. It's a conditional statement. Conditional statements test if expression is true or not.
- You can have more than one conditional statement by using else if.
- All values considered truthy except for: 0, -0, On, "", null, undefined, NaN, or Boolean data type with value of false.
- An Array is a stored group of related data, represented by a single variable. They are zero-indexed and sequential.
- Index is a unique number that identifies the location of a piece of data.
- A for loop uses a predictable pattern of indices to perform a task on all items in an array, by allowing a single code block to be executed repeatedly.
- You can comment out code by using /* before and */ after a block of code.
- A function is a set of instructions that tell the computer how to perform a certain task. They do not automatically execute and need to be called by name.
- JavaScript allows users to interact with a website.
- A semi colon at the end of a line indicates the end, is required when separating statements, but is good practise to use after every statement.
- The varaible types are: string, number, boolean, array, and object.
- Operators are mathematical symbols that produce results based on two values/variables.
- Operator types are: addition, subtraction, multiplication, division, assignment, strict equality, and Not, Does-not-equal.
- Events are code structures that listen for activity, and run code in response. Example: click event is fired by browser wen you click on something.
- Data types: null, undefined, Boolean, number, BigInt, string, and symbol.
- JSON (JavaScript Object Notation): lightweight data-interchange format, derived from JavaScript, used by many programming languages. It builds universal/transferable data structures.