Lab: Writing Web pages

Summary
We consider techniques for building and styling Web pages.

About Labs

In this course, we will use our synchronous meeting time to work on lab assignments that dive deeper into the concepts introduced in the reading. Practice, experimentation, and failure are the name of the game here. Labs are an opportunity for you to try things out, see what works and what does, encounter roadblocks, overcome them, and ask for help when stuck. This last part is why most of our lab work will be done in pairs, usually through pair programming. One of the secrets to practical problem solving is to put a fresh pair of eyes on the issue, something that your partner will continually provide.

At a distance, it is markedly more difficult to work collaboratively. Technological hurdles aside, such as spotty Internet connections, we miss subtle social cues in an online setting such as eye contact that makes communication more effective. Nevertheless, we believe that the benefits of collaboration are still well worth it.

To help mitigate these issues, you will find our lab instructions more prescriptive than a traditional lab. In particular, each lab assignment will be composed of multiple parts that you are required to complete individually or collaboratively as well as the time you should spend on each activity when appropriate. These prompts are there to help focus your efforts and ensure that you make adequate progress through the lab; please make sure to follow them!

Finally, note that labs are primarily meant to be an effort-based deliverable. As a form of practice, we don’t want to penalize you for incorrect answers since you will naturally make them in your exploration of the material. However, don’t let this fact mean that you can simply blow off the labs! Instead, you should use this opportunity to deeply explore the material with your partner rather than sprint through the lab. More specifically, you completely understand the solution that you produce. As a goal, you should never write something and think to yourself, “how did that work?” You should always challenge yourself and your partner to develop the capacity to explain what you have created.

Preliminaries

Individually, spend approximately 5 minutes setting up your environment for the lab.

  1. From the reading, you should have installed Atom on your machine to try out the example web page. If not, go ahead and download and install Atom now.
  2. In a Web browser, open the reading on HTML and CSS as a reference.
  3. Create a new folder in your csc151 work folder called sample-web that will house your work for this lab. In general, get in the habit of creating a new sub-folder inside of your work folder so that you don’t make excessive clutter.
  4. Download the following zip archive that contains the starter code for this lab to your sample-web folder:

    Navigate to this file in File Explorer (Windows)/Finder (Mac) and double-click it to extract its contents to the sample-web folder.

  5. If all went well, Inside that directory, you should see a few files with suffixes like .html and .css in sample-web now. These are the files we will modify for this lab.

Exercises

Exercise 1: Exploring a Web page

Let’s start by looking at the ThingymabobCoInc Web site from the reading. Spend about 10 minutes on this part of the lab.

  1. Individually, From Atom, go to FileOpen File, navigate to the sample-web folder you created, and open thingy.html. Note that Atom colors the different parts of the code, a useful feature called syntax highlighting.
  2. Spend a few minutes individually scanning through the page, identifying the different tags that are being used. Note them down on a piece of paper, and then check your work with your partner when both of you are done scanning the page.
  3. Individually, navigate to thingy.html in File Explorer/Finder and double-click it to open it in your default web browser similar to the reading. In Atom, make some changes to the page. You might, for example, add something like

    <p>
      We are proud to have acquired our long-term rival,
      <strong class="company">Whatchamacallit</strong> and will
      soon be disposing of their useless products.
    </p>
    

    When you are done, reload the page in your web browser to verify that the changes have taken effect.

  4. Share your change with your partner with the screen share feature of Collaborate. Take turns sharing your web browser screen by:
    • Opening the right-hand Collaborate panel if it is not open already. (If it is not open, should be a << button in the bottom-right corner of the screen that will open it up.)
    • Clicking the “Share Content” button, which is the box with the hook arrow (↱), and then choosing “Share Application/Screen.” And highlighting the change you made. When sharing your screen or web browser, please make sure that you only have safe-for-work material on your desktop! This includes wallpaper images and browser tabs.

Exercise 2: Exploring styles

As we noted, the design of the page is particularly hideous. You can read the details of the design in the file thingy.css. Spend 5 minutes and do this exercise individually, and share your work with your partner via screen sharing when you are done.

  1. Individually, open the file thingy.css with Atom. This file should also be in your sample-web directory. Note that Atom also syntax highlights this file!
  2. Individually, change the background color to something else. You might try gray or yellow or white. You can find an extensive list of possible colors at https://www.w3schools.com/cssref/css_colors.asp.
  3. Individually, save your CSS file, and reload the page in the Web browser. If you don’t see a change, try Shift-Ctrl-R in the Web browser.
  4. Spend a few minutes making the page less hideous by making further edits to the CSS file.

Exercise 3: Changing styles

In our description of CSS, we noted that one advantage of CSS is that it lets you quickly change the appearance of a page; let’s try that out now. Spend 2–3 minutes doing the following *individually**.

  1. Open the file mabob.css in Atom and spend a few minutes reading through it, taking note of the design decisions. Sketch what you expect the page to look like with this style sheet. Spend a few discussing with your partner what you believe the page will look like.
  2. If it’s not already open, open the file thingy.html in Atom.
  3. At the top of thingy.html, there’s a line that specifies that the CSS comes from thingy.css. Replace thingy.css with mabob.css.
  4. Save thingy.html and reload it in your web browser. Did the new CSS file behave as you expect?

Exercise 4: Building a new style sheet

In this next part, you will modify a new web page by building a new style sheet. Spend 15 minutes doing all of these parts individually.

  1. Open excerpt.html and excerpt.css in Atom.
  2. Skim through excerpt.html, taking note of the tags and styles you see.
  3. Skim through excerpt.css, taking note of any styles that are defined. (You should find only one.)
  4. Load excerpt.html in your Web browser to see how it appears.
  5. One benefit of electronic documents over printed documents is that color is much easier to use (or at least much cheaper). Update excerpt.css to assign different colors to the various people who are quoted (the king, the white queen, and Alice). I used red for the king, gray for the queen, and cornflowerblue for Alice, but you can use any colors you’d like. Reload the page to view your updates.
  6. As you may recall from our discussion of XML, a typographer might choose to make different kinds of quoted material appear differently. That is, spoken text might appear different than written text, and both might look different than introspective text (thoughts to oneself). Change those three kinds of text. You might use font-weight, font-style, font-variant, transform, text-shadow, or anything else you decide is appropriate. Reload the page to view your updates.
  7. The designers of most modern Web pages don’t extend the text to the browser’s left and right edges. Instead, they use margin-left and margin-right to add some visual whitespace. Update the style for the body tag to provide one-inch margins. Reload the page to view your updates.
  8. As long as we’re dealing with margins, it would be useful to indent the continued lines in Jabberwocky. Add a margin-left on those lines. I’d suggest the value 1em, which is the width of the letter “m”. Reload the page to view your updates.
  9. The default font family for the page is somewhat bland. Let’s experiment a bit. Try adding font-family: Helvetica, Sans; to the style for the body. This tells the browser to try Helvetica if it’s available, and, if not, use some simple sans-serif font. Reload the page to view your updates.
  10. You may have noted that the line spacing in the poem is inappropriate. That’s because each paragraph has a top and bottom margin. Update the .line class to use 0 for the top and bottom margins. Reload the page to view your updates.
  11. At this point, the stanzas all run together. Add top and bottom margins to the stanza to achieve some separation.
  12. At present, the title of Jabberwocky does not stand out. Some versions of the poem format it in all caps. However, modern typographers would probably prefer small caps. Update the title to use the following.

    font-variant: small-caps;
    

    You can also make any other changes you’d like.

  13. The source information is not strictly necessary. Let’s hide it. Update the style for p.source to use

    display: none;
    

    As before, save and reload.

Exercise 5: Your own story

Individually, using the tags and styles from the excerpt, spend 15 minutes create your own short story (with quotations) about Alice, the king, and the queen. (The goal of the exercise is primarily for you to get used to including tags and styles in the text you write.)

When you are done share your work with your partner via screen sharing!

Lab Turn-In

Usually, when you turn in your lab work, you will do so with a single combined turn-in for your pair. However, since the work is primarily individual (environment setup and testing), you will turn in your work individually for this first couple of labs.

Once you are done writing your story, please do the following to submit your work:

  • Upload excerpt.html and excerpt.css to turnin folder on OneDrive. Please ensure that the two files have precisely these names to ensure that our grading scripts pick up your work.

For those with extra time

Extra 1: Fun with fonts

Grinnell’s visual identity guidelines suggest that we use Futura and Freight Text Pro as our primary fonts]. However, both are expensive commercial fonts, and the College has chosen not to purchase a site license. As alternatives, our Communications department suggests that we use Arial and Georgia. Unfortunately, neither of these fonts is universally available (in particular, on machines running Linux).

Fortunately, there are a wide variety of open-licensed fonts available to us. My preferred alternative to Freight Text Pro is Besley, and my preferred alternative to Futura is Jost.

Using other fonts can be a bit more difficult. First, we have to tell the browser where to find information on those fonts. Then we update the font-family tag as you did earlier.

  1. Add the following line to the head of excerpt.html and save the file.

    <link rel="stylesheet" href="https://indestructibletype.com/fonts/Besley.css" type="text/css" charset="utf-8" />
    
  2. Reload the page. Do you see any differences? (You shouldn’t.)

  3. In excerpt.css, update the style for the body to use the following entry for the font family. Then save the CSS file.

      font-family: Besley, Georgia, Serif;
    
  4. Reload the page. Do you see any differences? (You should.)
  5. Google generously provides a wide variety of open fonts at https://fonts.google.com. Browse through the fonts, choose one, and figure out how to add it to your page.

Extra 2: Developing your own style sheet

You’ve now seen two style sheets for the same page and the significant effects a style sheet can have on the appearance of the page. It’s now time to design your own style sheet. The file company.css contains blank entries for the primary selectors you would use for the ThingymabobCoInc Web site. Design this webpage by filling in the entries found in company.css. Have fun experimenting with different styles and features!

One way to proceed is to think of a design, perhaps by drawing it on paper, and then challenging yourself to come up with the CSS that produces that design. We have only scratched the surface of what CSS has to offer, so if you can’t achieve what you want with the CSS we have discussed so far, feel free to search on the Internet for how you might proceed!