Lab 9 - Midterm 2 Review
Review CSS and Beginning JS for Midterm
Categories:
4 minute read
Recent Topics
- URL Paths
- can you embed an image from your own site in a page? (like one where the jpg or png or whatever is in your site’s directory structure, rather than already hosted elsewhere)
- can you link to the image with an anchor element?
- can you link to another page on your site?
- do all of the above work locally as well as if you deploy to either GitHub Pages or w3stu?
- HTML
- forms
- text input fields
- submit button
- forms
- CSS
- selectors (review css diner)
- specificity (review [specificity explainer(https://css-tricks.com/specifics-on-css-specificity/) and css specificity calculator)
- Styling (arbitrary short list of examples, no guarantees)
- color
- text
- background
- border
- link
- visited link
- link currently hovered
- “active” link
- position (review quokka)
- relative
- absolute
- fixed
- text
- (color)
- weight
- size
- units
- absolute vs. relative
- color
- Layout
- padding vs. margins for spacing elements
- horizontal centering
- Flex
- vertical centering
- spacing along the primary vs. secondary flex axes
- grid
- rows
- cols
- areas
- padding vs. margins for spacing elements
- Responsive
- media queries
- viewport units
- JS
- Dom element
- selection
- “CRUD” operations
- create (and adding into the document)
- read
- update
- delete
- Event handling
- listening
- click, change, input, submit
- listening
- Dynamic styling
- via the classList attribute is preferred (why is that?)
- via the style attribute when necessary (e.g. Prep 7)
- Dom element
Review Instructions
Setup
- Create a directory for this lab, mine’s called
e2-review
- to give yourself a chance to check your understanding about URL paths:
- add a subdirectory for styles (mine’s called
styles
) - add a subdirectory for images (mine’s called
images
)- find any (benign) image on the web and save it in this subdirectory
- add a subdirectory to group a few of the pages (mine’s called
about
) - in the
e2-review
directory, create anindex.html
- in the
about
subdirectory, create aindex.html
and ateam.html
- add a subdirectory for styles (mine’s called
- create a file called
base.css
in thestyles
subdirectory - add a file called
script.js
- just have
script.js
console.log
something for now
- just have
- in the html pages
- put valid starter code (I typically use vscode’s built-in html snippet,
!
+ tab) - link the css file
- for now tell the css to make the background of the body a color that’s obviously not white just so that you can easily tell styles your css file are being applied
- embed
script.js
in each of your html files - add enough elements to demonstrate all the CSS. I’ll use at least:
- a header
- a nav
- link to all pages
- a main
- an image
- show the image you downloaded on every page
- (interrupt yourself here and jump down to Testing and test both locally and deployed)
- a form with a few fields (tip: for now probably have the form’s action be
#
and the method beget
) - optional additions
- a few divs
- a few sections
- a few links
- a few lists
- put valid starter code (I typically use vscode’s built-in html snippet,
- in
base.css
add enough styles to demonstrate all the CSS topics listed above- for example, you might add a rule that will change the color of the text in the nav when the link is hovered
- you might add a rule that will change the background color of the body when the window is less than 500px wide
- you might add a rule that will change the color of the text in the header when the link is hovered
- you might add a rule that will change the bg color and text color when the user prefers dark mode
- add a class that will change the color of the text in any elements that have the class to “another color”
- (interrupt yourself here and jump down to Testing and test both locally and deployed)
- in
script.js
add code that will demonstrate all the JS topics listed above- for example, you might add a button that when clicked will change the background color of the body
- you might add a form that:
- has a text input
- when submitted
- add a new list item to an existing list in the page where the new list item’s content is 2 things:
- text content is the value of the input
- a button that when clicked will remove the list item
- the input should be cleared after the new list item is added
- make it such that every click on the list item itself toggles the color of the list item between the default and “another color”
- add a new list item to an existing list in the page where the new list item’s content is 2 things:
- (interrupt yourself here and jump down to Testing and test both locally and deployed)
Testing
- Use the VSCode Live Server extension to test your site locally
- how will you know if it’s working?
- you should be able to be able to use your links to navigate to all the pages
- the css should be applied to every page (background color should be whatever you set it to in
base.css
) - the image should be displayed on every page
- how will you know if the js file has been embedded and is working correctly?
- how will you know if it’s working?
- once the site is working locally, deploy to either GitHub Pages or w3stu and confirm that the url references all work:
- confirm the css is applied to every page
- confirm the image is displayed on every page
- test the links to other pages from each page and ensure they’re working
Last modified August 11, 2024: moved a bunch of things for archival purposes (6652bbe)