Web Development Flashcards
What three HTML elements do you use to build a description list?
description list
description term
description definition
How do you indicate the parent folder in a path?
Use ../ to indicate the folder above the current one, then the file name
Example: ../index.html
How do you indicate the child folder in a path?
Use the name of child folder, then the file name
Example: music/listings.html
How do you indicate the grand parent folder in a path?
Repeat the ../ to go up two folders, then follow with the file name.
Example: ../../index.html
How do you indicate the current folder in a path?
Use the file name
Example: index.html
What purpose do the thead and tbody elements serve?
thead: separate chunks in your table
tbody: the body (information) of table
Give two examples of data that would lend itself well to being displayed in a table.
Numbers, finances, anything you can put in an excel sheet
What is an absolute URL?
What is a relative URL?
Absolute URL: When you link to a different website, the value of the href attribute will be the full web address for the site
Relative URL: When you are linking to other pages within the same site, you do not need to specificy the domain name in the URL (example: <a>Home</a>)
What attribute do you have to match between a label and an input?
for and id
What attribute do you have to match between a label and an input?
for and id
Example:
Name:
What type of input allows you to select multiple items in a dropdown?
select
select needs to work with the element
What is the action of a form?
uses the action attribute to indicate the page that the data is being sent to
Give five examples of form control elements.
input option text area select button
Give three examples of type attributes for HTML input elements.
password email radio checkbox text calendar phone number button color date time file
Why would we choose specific element types when we have elements such as div and span which can be used for anything?
Provide elements that provide content
SEO (search englines)
Accessibility
What factors contribute to a well-designed HTML document?
Proper formatting (indenting)
Using the correct functions
What are the names of the individual pieces of a CSS rule?
property, value, selector, declaration
How are key/value pairs related to CSS?
properties and values
name that correlates to a value
Name three different types of values you can use to specify colors in CSS.
RBG Values
HEX
Color Names
Why must you have backup fonts assigned when selecting custom fonts?
In case the user does not have that font installed
If the fall back doesn’t work, it will default to New Times Roman
What CSS properties make up the box model?
padding, border, margin
content is not a CSS property
Which CSS property pushes boxes away from each other?
margin
Which CSS property pushes box content away from its border?
padding
What are three important considerations for choosing fonts?
Readability, cross browsers reading, theme, target market
In what situations might you need to apply styling to a single element multiple times in one stylesheet?
Mobile responsiveness
What is source order?
order that CSS rule is written
Styling provided for an element LAST in stylesheet
What is inheritance?
If the child element does not have a value, it would look to the parent element for a value
Why might CSS include the inheritance feature?
To set font related properties instead of setting it individually
Is inheritance a good tool to use for styling? If so, on what occasions?
Yes, because you can simplify setting properties
although its on the weaker side - any direct styling will override it
When is ! important a good tool to use?
NEVER. It’s used to override a template that you have no control over or for people writing libraries for CSS
What is specificity?
A browser decide which CSS property values are the most relevant to an element.. then apply it
The more unique, the stronger it’ll be
How is specificity calculated?
determined by the number of each selector type in the matching selector
Why might CSS include this feature?
To make things more precise to an element and not worrying about it getting overwritten
What is the order of selector strengths for CSS specificity (commonly referred to as the Specificity Hierarchy)?
id
class
element
universal selector
What is the CSS Cascade?
All the factors to determine what style is applied
What are CSS pseudo-classes useful for?
adds a specific selector to an element
What does the transform property do?
allows you to visually manipulate an element by skewing, rotating, translating, or scaling:
(adjust how the element represents itself visually on the page)
What is the difference between the :first-child pseudo selector and the :last-child pseudo selector?
The :first-child CSS pseudo-class represents the first element among a group of sibling elements.
The :last-child CSS pseudo-class represents the last element among a group of sibling elements.
What are 3 examples of what can be done with CSS transitions?
scale(grow or shrink), rotate, transition delay
Are all properties able to be transitioned?
no
List of properties that are transition-able: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties
Why is CSS transition a useful tool?
create elements to be more visually pleasing
another way to make website more comfortable for users
How do block-level elements affect the document flow?
start on a new line in the browser window
examples: h1, p, ul, li
How do inline elements affect the document flow?
some elements will continue on the same line as neighboring elements
examples: a, b, em, img
What are the default width and height of a block-level element?
100% (takes up any space available)
height: auto (same as content)
width: 100%
What are the default width and height of an inline element?
takes up space to accommodate its contents
height: auto (same as content)
width: auto (same as content)
What accessibility considerations must be considered when choosing HTML elements?
when you want emphasize through a spoken word (such as strong, em, del)
What is the difference between display: none and visibility: hidden?
display: none = hides an element on a page.. element will not be on the page at all (no spaces, no gaps)
visbility: hidden = hides an element.. all the other elements moves over it (shows a space for the hidden element)
What is the difference between the block, inline block, and inline display properties?
block: takes up full width
inline: takes up minimum space
inline block: takes up minimum space but with a set height and width
What is the initial display property of div s?
block
What is the difference between the block, inline block, and inline display properties?
block: takes up full width
inline: takes up minimum space
inline block: takes up minimum space but with a set height and width (you can resize height and width)
Why are CSS resets helpful for cross browser compatibility?
its good to be consistent across multiple browsers
Why is it important to be mindful of what you reset with your CSS resets?
you don’t want to reset everything as it’ll give us a starting point. you just want to get rid of things that will cause problems between different browsers
What is an argument against using CSS resets?
a lot of the styles are eventually overridden by our main stylesheet, which means that the reset styles unnecessarily add to page load time
What is an argument against using CSS resets?
a lot of the styles are eventually overridden by our main stylesheet, which means that the reset styles unnecessarily add to page load time (more work for browser)
What is the default value for the position property of HTML elements?
static
How does setting position relative on an element affect document flow and where the element appears on the page?
moves an element in relation to where it would have been in a normal flow
shift where it would normally be
How does setting position absolute on an element affect document flow and where the element appears on the page?
removed from document flow entirely and looks for the first non-static parent it can find to position itself against
What are the box offset properties?
top, bottom, left, and right
What were floats originally designed for?
to allow developers to float text around image elements similar to the way newspapers and magazines would display text. For example:
What are clears for with floats?
allows you to say that no element should touch the left or right hand sides of a box
can see floated elements
What are some of the downsides for using floats in layout design?
element is removed from the document flow
You need to make sure that every element is aware of the float (there is a lot of overhead to check in CSS)
What are the three core parts of a grid system?
container, row, column
Why should flexbox not be used for building complete web page layouts?
Flexbox is best for arranging elements in either a single row, or a single column.
Why is it important to use a grid system for CSS layouts?
Easier to edit in teams
individual: you can use the same tools that you’ve been using
Why is it a good idea to use percentages for grid column widths?
responsiveness (if you’re viewing it on different screen sizes, you do not have to write more codes to adjust to different screen sizes)
How do you think building this layout would be different without a grid system?
IT WOULD NOT BE FUN
It would be very tough…
What advantages do you see with using a grid system?
organized (easier to work with),
user friendly (easier for them to use and read)
Why are media queries crucial to responsive grid designs?
automatically adjust the set width of the container class depending on the size of the current browser window
without it, building responsive designs is almost impossible (it is important for the content of the website to adapt to the screen it is displayed on)
What is a variable?
to temporarily store the bits of information it needs to do its job
container that we can store data in and reference by data to be used later on
Why are variables useful?
ability to have something you can reference and use later
What two special characters can a variable begin with?
$ or underscore (_)
How do you declare a variable?
using the VAR keyword
ex. var quantity
Which words cannot be used as variable names?
JavaScript keywords
if, while, var, const
What is a string?
data type that consists of letters and other characters in a pair of quotes
What is the string concatenation operator?
joining two or more strings to create a single value using the string operator (+)
What is the difference when it comes to using single quotes or double quotes ( ‘ ‘ or “ “ )?
nothing
How do you escape quotation characters?
backwards slash before any type of quotation mark
example: a href="sale.html"
What is type coercion?
one data type has been converted from one data type to another
ex. concatenation var phrase = 'I am' var age = 29 var phrase2 = ' years old' phrase + age + phrase2
What is a number in JavaScript?
data type that contains a number
What is an arithmetic operator?
mathematical operator
Name four of the arithmetic operators?
multiplication, division, addition, subtraction
What is the order of execution?
PEMDAS
What is a boolean?
data type with the values of true or false
What is a comparison operator?
used to compare values to test for true or false comparisons
What is the difference between undefined and null?
null: empty or non-existent, must be assigned (ex. vacant lot in a city - i want to put something here but not right now)
undefined: value is not assigned; not on purpose (ex. a vacant lot in a city - could be empty for a variety of reasons)
What is the difference between undefined and null?
null: empty or non-existent, a value that has been set by someone (ex. vacant lot in a city - i want to put something here but not right now)
undefined: value is not assigned; not on purpose (ex. a vacant lot in a city - could be empty for a variety of reasons)
What is the difference between a parameter and an argument?
parameters: variables
arguments: values
What is a function?
performs a specific task
Define a function named addTwoNumbers with two parameters
function addTwoNumbers(a, b) { }
How do you call a function?
using the statements in between the parenthesis
What are the parts of a function definition?
functionKeyword functionName() { return statement }
name function
parameter list
return code block
CODE READING: var firstName = “Michael”;
The string, Michael, is being assigned as the value for the variable first name
CODE READING: var address = number + street
the value of the variable number is being concatenation (+) with the variable of the value street. The result of this expression is the variable address
CODE READING: var area = height * width
the variable stored for height is multiplied by the variable stored for width. The result of this expression is the variable address
CODE READING: var inStock = true
the Boolean true is being assigned to the variable inStock
CODE READING: var nullVariable = null
the value null is being assigned to the variable nullVariable
CODE READING:
function multiplyTwoNumbers(a,b) { return a*b }
Function definition named multiplyTwoNumbers with the parameters a and b with an opening curly brace for the code block. The value for variable a is being multiplied with the value for the variable b and the result of the expression is being returned to the function. there is a closing curly bracket for the code block.
Why are functions useful?
writing little code as possible with a pattern of work that needs to be accomplished
Why is it important to understand truthy and falsy values?
important for doing comparisons and conditionals
do not want to convert things to a boolean to determine if its truthy or falsy, we want to check the values.
Why is the typeof null object?
it’s a bug
Why do you always use === for comparisons?
to execute a true equality test
Why do you always use === for comparisons?
to execute a true equality test
convert values to similar data type to check for comparison
Do all if statements require an else statement?
no
Do all if statements require an else statement?
no
if there is an “else”, that means something has to happen
What is the proper syntax for using the or operator?
dual pipes/double pipes
x == 5 || y == 5 is false
CODE READING: if (value1 < value2) {
if statement with a condition checking if the value of the variable value1 is less than the value of the variable 2 with an opening curly brace for a code block.
What is the primary use case for switches?
used to perform different actions based on different conditions.
What is the primary use case for switches?
knowing what the user is looking for and goes directly to it without checking a list
Does the default case have to be at the bottom of the switch statement?
no (but for good practice, it is on the bottom)
What happens if there is no break statement between cases?
the next case will be executed even if the evaluation does not match the case
it will start doing the work of the next case (fall through)
–ex: case using *, x, X for multiplication
CODE READING: switch (operator)
Switch statement checking the EXPRESSION of operator
Difference between if and switch statement
ex. friend ask for a banana
if statements (checks one at a time) - you take one fruit out at a time until you get to the banana
switch statements (sees the full landscape and goes directly to the value you're looking for) - you have the banana on a stand
What is an object in JavaScript?
collection of related/reference data (contains memory type)
primitive data(contains actual value)
How do you create an object literal?
var object = { };
var object2 = new Object( ) ^ shorten syntax for creating a new object (not mainly used)
What is a property in relation to JavaScript objects?
a place where we can store data inside of an object
What is an array in JavaScript?
list (or set of values)
How do you create an array literal?
square brackets
Arrays have a property named length. Because arrays have a properties, what other data structure are they similar to?
(length is usually tied to an array = array.length)
CODE READING: colors[1]
value at the one index in the color array
DO NOT SAY FIRST…
What are the keys for the values inside an array?
numbers counting up from zero
Arrays have a property named length. Because arrays have a properties, what other data structure are they similar to?
(length is usually tied to an array = array.length)
objects
What are some good use cases for using objects inside arrays?
student data (name, age, grade)
insurance policy (name, plan, cost)
user info (email, password, full name)
CODE READING: var library = [ ]
there is an empty array literal being assigned as the variable for library
CODE READING: library[0].title
the value of the title property of the object at the zero index of the library array
CODE READING: console.log(library[1].author)
the log method is being called to an argument to the value o the author property of the object at the one index of the library array
What is the primary advantage to storing your selected elements in a variable?
we can reuse it later
Why might you need JavaScript to modify the DOM after the page loads?
gives interactivity (gives update for interaction quickly)
How can you better prepare when writing HTML for DOM manipulation in your JavaScript code?
put more information in elements (like setting attributes)
CODE READING: box1.classList.remove(“blue”)
the remove method of the object within the class list property of the box1 object is being called with the string argument blue
CODE READING: box2.style.height = “150px”
the string 150 px is being assigned as the value for the height property which is the property of the style object on the box1 object
What are the differences between innertext and textContent?
textContent:
- gets all elements (including script) render text of the page
- returns every element in a node
innerText: (you don’t normally use innerText)
- gets all “human-readable” elements
- aware of styling and won’t return hidden elements
- has to interpret the text/DOM
- takes a longer time to read
What datatype are the values you remove from a text input?
string
Why is it so important to be able to dynamically update text?
interaction for the user (like updating text box, etc.)
What are some of the drawbacks of HTML Event Handler Attributes?
better to separate the JS from HTML
Why is the Window.event property to be avoided in new code?
This property is not universally supported and even when supported introduces potential fragility to your code
Why is the Window.event property to be avoided in new code?
This property is not universally supported and even when supported introduces potential fragility to your code
changes with every single event and can easily go to a different event than you’re trying to work with
–ex. document.addEventListener(“mouseover”, console.log)
What is the difference between the getElementById() method and the querySelector() method?
The querySelector() method returns the first element that matches the specified css selectors. For example: document.querySelector(“div.target > span”);
The getElementById() method returns the first element that matches the given id in the DOM. For example: document.getElementById(“idOfSpan”);
Who passes in the event object into the handleClick callback function?
JavaScript language with automatically do it
Does a callback function require a name?
no (but you should name your functions)
this would be called an anonymous function
CODE READING: alert(“it works”)
alert function with the argument string it works
console log the event object which is passed in by the event handler when it calls the handleClick function
function handleClick(event) { console.log(event);
What is the purpose of a loop?
to repeat the same, or similar, code a number of times
currentTarget
targets the element that the event is dealing with
CODE READING: current++
there is the variable current followed by the ++ operator
DO YOUR INCREMENTATION AFTER YOUR WORK IS DONE
Why might there be different kinds of loops?
different situations
What is the purpose of a conditional expression as it relates to loops?
when you can stop
Could a loop potentially go on forever?
yes
Could a loop never start?
yes
How does a for loop differ from a while loop?
while: don’t know how many times you need to do something but do know where you’ll stop (Ex. walking to leasing office.. don’t know how many steps but i do know where to stop)
- -need a stopping place
for: know the number of items (aka arrays) we’re dealing with (ex. checking off boxes on a stack of cards – set number in a deck of cards)
- -need an initialization, condition, and final expression
What potential use cases are there for for loops?
arrays (example: search engine)
Which pieces of information provided in the parentheses for a for loop are mandatory?
none are mandatory
example: for(;;) –> but you could use while loop instead
What is a for in loop?
using a loop when you don’t know how many things there are in an object
How do you target the value of a property in an object.
put the variable of the property in a bracket notation
When should you use a for in loop?
loop over an object
When should you use a for in loop?
loop over an object [and do the same action for each property]
When should you use a for in loop?
loop over an object [and do the same action for each property]
least use type of loop
What is node
a piece in your document
What is the difference between the parentNode and parentElement properties?
parentNode: document of the parent element
parentElement: parent element of the current node (always an element)
Why is it important to be able to traverse the DOM?
whitespace nodes and allows us to find information on elements around us
What kind of information is useful to store in custom attributes?
use data attributes to store information
example USING DATA SET
What are two ways to target elements on the DOM?
querySelector (selects first element it finds) or getElementbyID or
querySelectorAll (looks for every single element that may have that class or attribute - but will always return a node list)
What is another way to add a text node to an element other than using textContent.
inner text (use when you want to avoid whitespace node)
document.createTextNode
How do you create a HTML element using vanilla Javascript?
create element method of the doc element object
Why is using loops and arrays for creating multiple dom elements preferable to creating them one at a time?
DRY (do not repeat yourself)
saves you time!!
Why are arrays preferred over objects for the functionality referenced in question 1?
(Q1: Why is using loops and arrays for creating multiple dom elements preferable to creating them one at a time?)
arrays have order and have index
objects do not have order
How would you alter the game to make the choice from 1 - 500?
var randomNumber = Math.floor(Math.random() * 500) + 1
math. random() = function that gives you a decimal between 0 and 1 but not actually 1… gives opportunity for random percentage.
math. floor() method chops off the decimal point; it’ll round it off to an integer.
+1 = if i get 99.999 repeating, after math.floor it’ll be 99 instead of 100. Which is why you add 1.
example: range between 25 - 50
math.floor(math.random() * (50 - 25 + 1)) + 25
[THAT SHOWS MAXIMUM MINUS MINIMUM AND ADDING 1 TO INCLUDE 25]
What are the disadvantages of inline styling via JavaScript?
you do not want to mix up languages
major problems with inline styling
if you have to do it, it would be where you need to make a math calculation
What things do you have to consider when building a reset game function?
generating a new number to guess if replaying
setting everything back to its initial value