- HTML
- CSS
None
- Learning to style HTML using CSS
- Receiving and incorporating constructive feedback on a project
In this project, you will create a well-designed webpage that displays one of your favorite recipes. It will include the ingredients, the steps needed to make the dish, links to similar recipes, and at least one photo.
Phase 1 of the project involves coding the structure of your webpage using HTML. This includes the ingredients, the steps needed to make the dish, links to similar recipes, and at least one photo.
Phase 2 of the project involves adding styling and pizazz using CSS. This includes changing the font style, font size, colors, and significantly altering the layout.
Phase 3 of the project involves incorporating JS DOM methods. You'll add at least three interactive elements of your choosing (next week).
Note: There used to be a "Bootstrap" part of this project, but Bootstrap is no longer a part of the Techtonica curriculum. If you'd like to research and incorporate a library to streamline the CSS process, you can do that on your own.
- You completed a basic HTML page in Phase 1
- You learned basic CSS syntax and rules in the intro lesson
- Let's style your HTML with CSS!
- Create a file tree for your Recipe Page project
- Create a CSS file in the proper directory of your file tree
- Link to your CSS file from within your HTML
<head>
tags - Change the background color of your webpage
- Change the font and font color of your headings and paragraphs
- Constrain the description to the width of the image
- Make the image and ingredients appear on the left
- Make the instructions appear on the right
If you have questions, do not disturb your colleagues until you have spent at least 20 minutes troubleshooting on your own. Be sure to format your question using the template we practiced in the Asking Good Questions lesson.
You'll be building on the HTML code you completed in Phase 1 of this project.
Try to build in your local desktop file this time, since CodePen won't help you understand how the HTML and CSS are connected. Remember that you'll need to save (command + s
on Mac) and refresh your browser page to see new CSS changes.
Note: If you are using an online editor such as Replit or Codepen please ignore this part for now
- On your desktop, create a folder called
techtonica-projects
. Inside that, create a folder calledrecipe-page
. Move yourrecipe-page.html
file intotechtonica-projects/recipe-page
. If you no longer haverecipe-page.html
, make it again with the Challenge directions from Phase 1. - Use TextEdit or WordPad to make a new file called
styles.css
. Make sure it is in thetechtonica-projects/recipe-page
directory right next torecipe-page.html
. - Now that it's in
techtonica-projects/recipe-page
, it's obvious what your HTML file is for. Renamerecipe-page.html
toindex.html
.
- In
styles.css
, add this small bit of CSS code to the file, then save the file.
p {
color: blue;
}
We're doing this so we can easily see if we've successfully connected styles.css
to index.html
. We'll know it worked if all of our paragraph text appears blue instead of the default black when we load index.html
at the end of this step.
- Now we need to link to
styles.css
from withinindex.html
. Openindex.html
. Read the following code snippet and make sure you understand what it does. Then, copy and paste it into the<head>
area ofindex.html
, just below the<meta>
tag.
<link rel="stylesheet" type="text/css" href="styles.css" />
Questions to Consider
- What are
rel
,type
, andhref
called? - What are
"stylesheet"
,"text/css"
, and"styles.css"
called?
Open index.html
in Chrome. The blurb under your title should be blue!
When you're satisfied that styles.css
is properly linked to index.html
, run git status
. Add and commit, making sure to write a descriptive commit message in the present tense, such as "Links stylesheet to index."
If you want to change your paragraph text back to black from the temporary blue, do so now by simply deleting all the code in styles.css
.
Now, write some CSS code in styles.css
that will change the background color to any color you like!
- You can use this color picker to find the right hexadecimal color code.
- Or you can use Digital Color Meter, an app that ships with MacOS that can tell you the color of anything showing on your screen. Hit
cmd + spacebar
to bring up your Spotlight window, and begin to typecolor
. After you select and launch Digital Color Meter, you'll see a small window that "picks" the pixel your mouse is currently hovering over. There is no dropdown option to show the color values in hexadecimal, so you'll have to use a piece of scratch paper, write down the RGB values, and use an online converter to get the hex code (Google provides one if you search forrgb to hex
). - Keep in mind that readability is really important. It's very hard for most people to read screens that have really bright backgrounds (yellow, orange, red, pink) or really dark backgrounds (black, brown, navy).
Refresh index.html
in Chrome by pressing <COMMAND> + r
. Does your new background color show up?
When you're happy with the background color, run git status
. Add and commit, making sure to write a descriptive commit message in the present tense, such as "Changes background color."
- Select all the headings by writing CSS code inside
styles.css
and change the color to something that works well with your background color.
- Hint 1: Can you figure out how to use multiple selectors for the same style change, rather than writing code for each one separately?
- Hint 2: Use the drop-down menu on the color picker website to easily find contrasting and complementary colors.
Refresh index.html
in Chrome by pressing <COMMAND> + r
to see if it worked!
When you're happy with the new font color, run git status
. Add and commit, making sure to write a descriptive commit message in the present tense, such as "Changes font color."
- Find a Google font that you think works well with your color scheme, recipe, and the overall vibe you want to create on your webpage.
When you find a font you want to use, click the "Get Font" button in the upper right-hand corner. A black strip will appear at the bottom of your browser.
You'll now see a pane that contains some HTML code and some CSS code. Copy and paste these code snippets into the proper files in order to include this new font in your project.
Refresh index.html
in Chrome by pressing <COMMAND> + r
to see if it worked.
If you need to make the font size larger or smaller for your headings due to the new font's default size, go ahead and make these changes now in styles.css
.
When you're happy with the new font, run git status
. Add and commit, making sure to write a descriptive commit message in the present tense, such as "Links to Google font for headers."
You may remember from Phase 1 of the project that we constrained the width of the image to 600px. (If you haven't done this yet for some reason, please do so now.) Let's now also constrain the blurb text underneath the title to a width of 600px, to make it easier for the user to read.
The description is currently inside a pair of <p>
tags. But if we use the <p>
element as a selector, any paragraph text we add later will also be affected by the 600px constraint. A better way to select the description is to give its opening <p>
a class called "description" and then use .description
as a selector in styles.css
. Go ahead and do this, implementing the width constraint to 600px on your own.
Refresh index.html
in Chrome by pressing <COMMAND> + r
. Did it work?
When you've successfully constrained the width of the description to match the width of the image, run git status
. Add and commit, making sure to write a descriptive commit message in the present tense, such as "Constrains description width to 600px."
Right now, the entire webpage is displayed in a vertical fashion. We can make all the content appear on the screen, side by side, and eliminate the need for a user to have to scroll to read everything.
We've already accomplished some initial steps for making this happen. We have the title and description in their own <div>
which has a class called top
. If we don't specify any layout styling for this div in styles.css
, it just defaults to taking up the whole width of the screen. This is what we want, based on the layout image shown in the instructions.
We've also created divs that have a class called left
and right
, respectively. Can you guess what we're going to use those classes for? We're going to use them as CSS selectors!
- In
styles.css
, use theleft
class as a selector. We want to constrain the width of this div to 600px so that it aligns perfectly with the image above it. Implement that now. We also want it to float on the left. Implement that now, too.
Refresh index.html
in Chrome by pressing <COMMAND> + r
. Do you see a change to your layout?
You should see that while the div with the left
class has stayed on the left, the div with the right
class is now on the right and overlapping some of the content. Progress! Let's fix that silly overlap in the next step.
When you've successfully made the <div>
with the .left
class float on the left of the webpage, run git status
. Add and commit, making sure to write a descriptive commit message in the present tense, such as "Float half the content on the left."
- In
styles.css
, use theright
class as a selector. We want to constrain the width of this div to 600px so that it matches the width of the image and the left div. Implement that now. We also want it to float on the left of its allotted space. Implement that now, too.
Refresh index.html
in Chrome by pressing <COMMAND> + r
. Do you see a change to your layout?
No more overlap!
Play around with the float position of the right
class. What happens when you use float: center;
and float: right;
? Why do you think this happens? Reset back to float: left;
when you're done.
-
Let's add a little bit of blank space between the two divs. Using the
margin-left
property, add at least 30px of space onto theright
div. -
If the top of your image is not aligned with the top of your instructions, add a
margin-top
property to theleft
div so they match.
Voila!
When you're happy with the layout of your webpage, run git status
. Add and commit, making sure to write a descriptive commit message in the present tense, such as "Completes styling and layout."
- What, if anything, was challenging about this phase of the project?
- What did you enjoy the most while working on this phase of the project?
- What questions came to mind as you were working through the steps?
- If you were to explain to a bright child what you worked on during the phase, what would you tell them?
- We can add common FAQs here. Open a GitHub issue or PR if you have any questions.