Information Foraging Studio
After completing this studio, you should have the basic technical skills necessary to complete the Information Foraging Project. Note that you can successfully complete this project simply by rearranging information within HTML. However, some students have wanted to make changes to the visual design and interactive behaviors of the site. So, this studio gives you a taste of how to do all of these things. By the end, you should hopefully be comfortable making changes to the nursery school site and have an idea about how to implement the changes you envision.
Contents
General model
For those who have never done any web programming before, we'll end up touching three kinds of files:
- Html contains static information and its' organization (*.HTML)
- Css allows you to set the visual properties and control how different website elements look (*.CSS)
- JavaScript enables your site to have interactivity and respond to what users do (*.js)
Running the Nursery School Site
- Open a terminal window or the terminal in your code editor.
- Navigate to your repository folder. This should be something like: information-foraging-<YOUR_GITHUB_ID>.
- Start a local webserver by typing in (from your repository directory):
npm run dev
. The nursery school site should be opened for you in a web browser.
Finding Content in HTML
Today's web browsers provide developer tools that can be handy in finding things you want to modify in the nursery school site. For purposes of this studio, we'll assume you are using Chrome. We're going to start by changing the "Visit Our School" call to action in the center of index.HTML. In some cases, you can just search for text in the page within VSCode. In other cases, you may need to navigate around more in the HTML structure. For this, the developer tools can be extremely helpful.
Opening the Developer Tools: First, we'll open the developer tools. From the three dots menu all the way on the top right, choose "More tools" and then "Developer tools."
A Quick Tour of the Element Pane:Now, you should see a panel open on the right hand side. The elements area of the developer tools shows the structure of the HTML document open in Chrome. Using the element pane, you can look at the structure of the information in the document. In HTML, different types of information are enclosed in tags. For example, a link looks like this:
<a class="site-title" href="/information-foraging/files/index.HTML">Nursery School</a>
- The <a> and </a> define the beginning and end of the link information.
- Inside the <a> tag, there are some properties defined: the address to link to (href) and a class that can link to CSS formatting instructions.
- Between <a> and </a>, we see the link text that appears on the page: Nursery School
If you want to find a specific item on the page there are two ways to do so:
- You can hover over elements in the element pane, and they will get highlighted in the page. Note that HTML is hierarchical, so you may need to tunnel into child elements to find what you need.
- You can also right click on the element you want to find and choose Inspect from the pop-up menu.
Task: Use the developer tools to find the visit call to action.
Question: What is the opening HTML tag for the entire gray region? Note: this should be something like: <tagType propertyName="propertyValue">
Changing Menu Names
Some of the HTML elements are replicated in a number of pages. To enable you to make changes to them in a single place, they are dynamically loaded for you. But, you'll have to find them in a different location than the rest of your HTML files. Here is a quick run down for how to use them Modular HTML Components.
Task: Inspect the menu item "Parent Resources" and take a look at it's ancestors.
Question: What is the ts-load element that it descends from?
When you find a ts-load element, that means it is one of the special dynamically loaded ones. The data name property gives you the name of the HTML file to go looking for. However, you need to find it in 'scripts/ts/dynamic-dom/html.
Task: Change the menu item "Parent Resources" to "Recommended Reading". When you save the file, your local version should automatically refresh and you should be able to see your new text.
Question: What does the html for the menu header look like now?
Finding and Modifying CSS Properties
When you select an HTML element in the Elements pane, you can see its relevant CSS styling information in the pane immediately below. Note that these can also be hierarchical, so the Styles scrollpane shows you all of the relevant CSS for the selected element. Many of the names are self-explanatory, but searching for "<HTML TagName> <propertyName>" is a good way to find documentation and examples. So, for example, a search for "p line-height" explains that it's basically a way to change the line spacing, specified in pixels.
Sometimes, the properties currently used in CSS won't do what you want. You can also look up how which properties are available for a given HTML element. Searching for "<HTML TagName> properties" like "p properties" can help you determine what kinds of styling options are available.
Troubleshooting: Browsers like to cache .CSS files and are often fairly aggressive about not reloading them. So, if you change things and they don't show up when you reload the page, you may need to clear your cache information. On Chrome you can do this from the three dots menu. Select More tools and then Clear browsing data.
Task: Currently, there's an 80 pixel border around "Visit Our School", the "Our students..." sentence and the "Contact Us" button. Figure out how to change it to a 60 pixel border. Then, make it so that "Our students..." text has a larger inset from the border (i.e. make the text occupy a narrower space and the gray space to the left and right is larger). Note: To accomplish this, you will need to change one existing CSS property value and add at least one new one.
Question: What are the modified CSS specifications needed to accomplish this? (Just the ones for classes you changed.)
Defining New CSS Properties
CSS styles are hierarchical, with more specific formatting rules taking precedence over more general ones. So, for example if a specification for a paragraph element sets a font and font color and then a paragraph element for a specific class sets different values for these things, the specific class's values win for that class. For more details, check out: Specificity and The Cascade.
An Example Style That Cascaded
Task: Use the web developer tools to find the HTML element for "Classroom News" and look at it's styling.
Question: Where is the CSS specification that defines which font is used (e.g. Arial, Times New Roman, etc)? Hint: if you've found the right thing, you should see that the font property is inherited.
Making a New Style
Task: Suppose you wanted to make the Classroom News header stand out more. Define a new style specification to make it's font size twice as big as the standard font size. This change should not effect the Announcements header next to it. Hint: You may need to assign a class to the relevant HTML and define a style for that class.
Question: What does your CSS code look like?
JavaScript
Sometimes, it's helpful to change the visual properties of something as a user interacts with a page. One example of this is a sticky header. A sticky header does something very simple: it defines two different styles for a given html element. Then it uses a simple listener to figure out when the header isn't visible on the screen. If the header is visible, it uses the normal style with the header on top of the body element. If it isn't, then it uses a different style that displays the header at the top of the screen, even if it is over part of the body element.
Task: Follow this tutorial on how to create a sticky tutorial and adapt it to work with the Nursery School site. Sticky Header Tutorial
Some hints: You'll need to determine which html element is the header - use the one that shows the menu of navigation options. Then, you'll need to figure out how to make a sticky style that can be used for that element. Finally, you'll need to add the javascript. You can insert it directly in the page. Or, you can make a new js file and instead insert that page.
Question: What is the id for the html element associated with the header?
Question: What is the css definition for sticky as defined for your header element?