Lab 05 The Onion
Goal
- HTML: Learn
<sections>
,<articles>
,<footers>
, and other uses for<a>
. - HTML comment tag
- CSS: Pseudo-classes, and border property
Learn
New HTML
<section>
<h2>Famous Wizards</h2>
<p>Gandalf, Dumbledore, Rincewind...</p>
</section>
<section>
- represents a standalone section which doesn't have a more specific semantic element to represent it contained within an HTML document. Typically, but not always, sections have a heading.
<article>
<h2>How to be a wizard</h2>
<ol>
<li>Grow a long, majestic beard.</li>
<li>Wear a tall, pointed hat.</li>
<li>Have I mentioned the beard?</li>
</ol>
<footer>
<p>© 2018 Gandalf</p>
</footer>
</article>
<article>
- represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributed or reused. Examples would be a forum post, magazine or newspaper article, or a blog entry.
<footer>
- element represents a footer for a section of content. Typically <footer>
are used in a <section>
, <article>
, <main>
, or <body>
. A footer typically contains information about the author of the section, copyright data or links to related documents.
<a href="importantdocument.pdf">Important Document</a>
<a href="mailto:hansontm@uwec.edu">Email Me</a>
<a href="tel:123456789">Call Me</a>
<a href="#one">Go Section 1</a>
<section id=one>
<p>...</p>
</section>
<a>
- Thus far we have only used the <a>
anchor tag to create a link to a website, but there are other possibilities. Using the href attribute you can link to a file (like a pdf), telephone number, email address, and locations within the same page.
file - When linking to a file use the url or file path in the href.
email - When linking to a email address use mailto: followed by the email address in the href.
phone - When linking to a phone number use tel: followed by the phone number without spaces or dashes in the href.
id - When creating a jump link to an id use # followed by the ID attributes value.
CSS
div{
border-width:.125rem;
border-style:dashed;
border-color:red;
}
div{
border:.125rem dashed red;
}
border-width
- sets the width of an element's border.
border-style
- sets the line style for all four sides of an element's border.
border-color
- sets the color of an element's border.
border
- shorthand for all border settings. Values must be in this order: width | style | color
Values for border-style:
- none
- hidden
- dotted
- dashed
- solid
- double
- groove
- ridge
- inset
- outset
CSS Pseudo-class
a{
color:blue;
}
a:hover{
color:red;
}
Is a keyword added to a selector that specifies a special state of the selected element(s). For example above the <a>
font color is blue, but when the user hovers over it, it will turn red.
HTML Comment Tag
<!--This is a comment. Comments are not displayed in the browser-->
The comment tag is used to insert comments in the source code. Comments are not displayed in the browsers.
You can use comments to explain your code, which can help you when you edit the source code at a later date. This is especially useful if you have a lot of code.
Practice
Experiment Try adding a dashed yellow border to the a. Then add a new declaration for the hover state on the a. For hover change the background color to yellow, font color to blue, and the border to blue.
HTML
CSS
Preview
Open GitHub Desktop (you may need to download the program again if the computers get wiped.)
Couple of things to check in GitHub Desktop.
- Check to see if it says Pull Origin in the top right tab. If it does, click Pull Origin. Why? A pull occurs if you or a collaborator made a change to the repository and pushed the changes. ALWAYS MAKE SURE TO PULL BEFORE CODING!
- If the computers were wiped you made need to reclone your repository to the computer.
With your cs-318 repository selected, Click open in Visual Studio code.
Create a new folder called lab5
Create a new file called index.html in the lab5 folder
Setup your HTML file
Create your stylesheet
Link your stylesheet to the HTML
Create an images folder.
Add the following svg to the images folder
the-onion-logo.svg
Note this image is white. When you open it in the browser right click on the white space and select save image. I promise the image is there.
Change Document in the title element to "The Onion"
In the <body>
element create a <header>
, <main>
, and <footer>
in that order
Add three <section>
to the <main>
Add the following content into the <header>
"The Onion News Sports Entertainment"
Add the following bullet points of content into the <section>
- News New Study Finds Americans Scoot Over At Least 10 Miles Per Year WASHINGTON" A new study published Wednesday by the Department of Transportation reveals that the average U.S. resident travels some 10 miles annually solely through the act of scooting over to make room for another person. Between park benches, bleachers, backseats, and various other types of shared, communal seating, the typical American scoots nearly a mile a month, said Department Secretary Anthony Foxx, who added that, taken all together, a lifetime's worth of scooting over, sliding over, scooching, and making a bit more room would equal the distance from the nation's capital to Orlando, FL. The statistics are even higher in the South, where picnic season is longer. And if you count instances of scooting over, seeing the other person has already found a place, and then scooting back, many Americans travel farther by scooting than they do by motor vehicle. The study's methodology has come under fire from critics who argue it should have also counted situations in which sitters must move their chair over to make room for someone who already has their own chair. The Onion September 18, 2013 Black Guy Asks Nation For Change CHICAGO ā€¯According to witnesses, a loud black man approached a crowd of some 4,000 strangers in downtown Chicago Tuesday and made repeated demands for change. "The time for change is now," said the black guy, yelling at everyone within earshot for 20 straight minutes, practically begging America for change. "The need for change is stronger and more urgent than ever before. And only you the people standing here today, and indeed all the people of this great nation only you can deliver this change." It is estimated that, to date, the black man has asked every single person in the United States for change. "I've already seen this guy four times today," Chicago-area ad salesman Blake Gordon said. "Every time, it's the same exact spiel. 'I need change.' 'I want change.' Why's he so eager for all this change? What's he going to do with it, anyway?" After his initial requests for change, the black man rambled nonstop on a variety of unrelated topics, calling for affordable health care, demanding that the government immediately begin withdrawing troops from Iraq, and proposing a $75 billion economic stimulus plan to create new jobs. "What a wacko," Schaumburg, IL resident Patrick Morledge said. "And, of course, after telling us all about how he had the ability to magically fix everything, he went right back to asking for change. Typical." "If he's really looking for change, he's got the wrong guy," Morledge added. Reports indicate that the black man has been riding from city to city across the country, asking for change wherever he goes. Citizens in Austin, TX said they spotted the same guy standing on the street Friday, shouting far-fetched ideas about global warming. Cleveland residents also reported seeing him in a local park, wildly gesticulating and quoting from the Bible. And last week, patrons at the Starlight Diner in Cheyenne, WY claimed that the black man accosted them while they were eating, repeatedly requesting change. "I saw him walk in and I knew he was headed straight for our table," said mother of three Gladys Davies. "He just stood there smiling at us for a while, and asked how our food tasted. Then he went and did the same thing at the next table over. The nerve of some people." Those who encountered the black man Tuesday said he engaged in erratic behavior, including pointing at random people in the crowd and desperately saying he needs their help, going up to complete strangers and hugging them, and angrily claiming that he is not looking for just a little bit of change, but rather a great deal of change, and that he wants it "right now." "I'll be honest, when that black guy said he would 'stop at nothing' to get change, it kind of scared me," local mechanic Phil Nighbert said. "Just leave me alone." Though many were taken aback by the black man's brazen demands, some, such as Jackson, MS's Holly Moser, sympathized with him. She gave the black man credit for boldly standing up and asking every last person around him for change. "I told him I'd give him some if I saw him later, even though I probably won't," Moser said. "Very nice man, though." Most, however, ignored his requests. "I'm a hardworking American who pays his taxes, and the last thing I need is some guy on the street demanding change from me," said William Overkamp, a Springfield, IL gun-shop owner. He added, "What he really needs is a job." The Onion March 19, 2008 Wealthy Teen Nearly Experiences Consequence SOMERSET, NJ In what local authorities are calling a "near tragedy," Charles Wentworth, a 17-year-old Rutgers Preparatory senior and member of the affluent Wentworth family, came perilously close to suffering a consequence resulting from his own wrongdoing Saturday. Wentworth, reportedly ignoring the protests of his classmates, got behind the wheel of his turbocharged Supra 2000GT after consuming half the contents of a bottle of Goldschlager at a friend's party. While driving westbound on Route 27, a disoriented Wentworth drifted across two lanes of traffic and collided with a minivan carrying a family of four, bringing the teen face-to-face with a potentially life-altering lesson. Wentworth escaped unscathed and unpunished, however, when his airbags deployed and a team of high-powered attorneys rushed to the scene and rescued him from the brink of personal responsibility. "Amazingly, Mr. Wentworth did not experience a single repercussion for consuming alcohol under age or operating a motor vehicle while intoxicated, and is furthermore completely unaware that he did anything wrong," local police chief Marvin Taylor said. "He is a very lucky boy." "If he had been driving just 5 mph faster, or if his parents hadn't had the influence to keep the matter out of court and the endless financial resources to lease a car of the exact same make and model to prevent him from having to face even the relatively trivial humiliation of being taunted by his peers for driving a slightly less expensive vehicle my God, who knows what could have happened?" Taylor added. "He could have died or, worse, been held accountable for his actions." According to police reports that have since been shredded and stricken from Wentworth's permanent record, when briefly taken into custody, the privileged teenager began swearing, vomiting, and kicking at the windows of the squad car in which he was momentarily placed following the collision. Wentworth later said the only thing that got him through that dark time was thinking of his rich, well-connected loved ones. With them in mind, he repeatedly shouted, "Don't you know who I am?" and summoned the strength to refuse a field sobriety test. "A lot of kids in Charles' situation would have confessed and accepted punishment for their mistake, but my son is strong," said Wentworth's father, aluminum magnate Herman Wentworth, who after arriving at the crash site told his son that "everything is taken care of," and while Charles sat in his father's BMW texting his friends, loudly threatened to call the police commissioner if any charges were pressed. "Charles would never allow himself to give up and gain valuable insight into the way things work in the real world without a fight." District Judge and close friend of the Wentworth family Donald Lamb agreed. "Charles is very lucky to be alive and well-off," Lamb told reporters. "The fact that he was able to walk away from this crash with no injuries, zero remorse, and his skewed priorities in one piece is a miracle." Despite returning to the safety of his $2.3 million home, Wentworth's harrowing brush with consequence was not over. A week after the near ordeal, Wentworth was again put in jeopardy of learning a lesson when he was nearly sentenced to 50 hours of community service. Tragedy was averted, however, when his mother paid a consultant to testify before the judge that Wentworth had suffered emotional trauma. Further, during this time, Wentworth was forced to put his video game on pause for several seconds in order to sign affidavits stating that the Breathalyzer was administered improperly. "To think that I was that close to seeing that there is an entire society with its own laws and standards outside my protected sphere of wealth and privilege it's frightening," Wentworth said. "It almost makes you consider your actions and their impact on others. Almost." "I'm just grateful I can finally get back to my life as a self-centered prick who believes the entire world revolves around him," Wentworth added. "After all, I was just admitted to Columbia despite almost failing out of high school because I rarely attended class, and it would have been a shame to have had to defer for a semester just because of some legal unpleasantry." At press time, Wentworth is resting comfortably on a six-figure inheritance in a chaise lounge by his backyard pool. The other four victims of the crash remain in intensive care at St. Peter's University Hospital, suffering from conditions ranging from poor to lower-class. The Onion September 27, 2008
- Sports Report: Chucking A Baseball 99 MPH Past Highway Radar Speed Sign Remains Best Indication That You Still Got The Goods The Onion September 19, 2019 Nike Recalls Sweat-Wicking Shirts That Pulled Gallons Of Liquid Directly From Wearers' Bodies BEAVERTON, OR" Warning customers to return the garments should they find themselves being drained of all fluids, Nike recalled thousands of sweat-wicking shirts Tuesday that inadvertently pulled gallons of liquid directly from wearers' bodies. If you or anyone you know puts on a Legend Dri-FIT short-sleeve training shirt and then immediately shrivels into a dried, wrinkled husk, please contact Nike for a full refund, said spokeswoman Jessica Garland, who apologized directly to customers who purchased a moisture-wicking shirt, only to have every ounce of sweat, urine, and blood sucked out of their body. You may think it's okay to wear these shirts for a routine workout at the gym, but be warned after five minutes of use, you could lose up to 40 pounds of water weight. Even if you wear it to sleep, you could wake up as nothing but a pile of desiccated flesh lying in a puddle. At press time, Nike was forced to issue a second apology after news broke of a million-dollar lawsuit alleging their compression tops had crushed the torsos of athletes into an infinitesimally small speck of dust. The Onion September 19, 2019
- Entertainment Space Jam 2 Taps Mahershala Ali To Play LeBron James The Onion July 25, 2019 Tom Hanks Recalls Arriving On A Beautiful Day In The Neighborhood Set At Dawn For Grueling 6-Hour Cardigan-Application Process LOS ANGELES Saying the process called for incredible patience, Tom Hanks, who stars as Fred Rogers in the forthcoming A Beautiful Day In The Neighborhood, recalled Tuesday having to arrive on the set of the film before dawn each day for a grueling, six-hour cardigan application process. I was always at the trailer by 5 a.m. so the cardigan artist and his team of eight assistants could spend the entire morning applying the sweater, said the two-time Academy Award winner, adding that it was incredibly difficult to act in the unwieldy garment, as it was very itchy and the chemicals used to apply it often burned his skin. We were working with the top cardigan guy in Hollywood, and he spent months taking molds of my torso so he could build a sweater that would look as realistic as possible on screen. I love how it turned out, but boy, all that time spent holding perfectly still in the chair can wear you down, especially when you consider it took them an additional three hours to apply my tie. At press time, sources close to the actor confirmed Hanks was furious after learning the studio had decided to go with a CGI sweater. The Onion July 23, 2019
Add the following content into the <footer>
"Email Us Call Us PDF of Articles"
In each <section>
add a <h2>
around the first word; News, Sports, Entertainment
In the <header>
add a <h1>
around "The Onion"
In between The and Onion in the <h1>
add a <br>
Add three <a>
in the <header>
. One around News, Sports, and Entertainment
Add one <nav>
around all three of the <a>
.
We will be setting up the href as a jump link later using an id attribute
Inside the <section>
divide up the news articles into individual <article>
elements.
Tip: each article ends with a date. Also you can use the pdf to see the content of each article to help you break them down.
- 3
<article>
in the first section - 2
<article>
in the two section - 2
<article>
in the two section
Add a <h3>
to the each <article>
element to the article's title (7 total titles).
Add a <footer>
to each <article>
around the content at the end; "The Onion" and "Month, Date Year"
Add a <p>
around the content inside the <footer>
. In the <article>
only, not the very last <footer>
on the page.
Add a <span>
inside of the <p>
you just added, around just "The Onion".
Hint:We are putting a span around "The Onion" because we will add some specific styling to just that content but still want it to be inline with the date. See the example below.
<p><span>The Onion</span> September 27, 2018</p>
Add <p>
around the individual paragraphs in the articles (27 paragraphs total).
Hint: Two of the articles have no paragraphs. If you are having a hard time figuring out where each paragraph begins and ends look at the pdf.
Add all the following images into your images folder.
Add an <img>
into each <article
> after the <h3>
- Article 1 - scoot.jpg
- Article 2 - obama.jpg
- Article 3 - wealthy-teen.jpg
- Article 4 - baseball.jpg
- Article 5 - nike.jpg
- Article 6 - mahersalaali.jpg
- Article 7 - tomhanks.jpg
Add the logo as a <img>
element before the <h1>
in the <header>
.
Hint: If you refresh your page and your content has disappeared don't panic, scroll down a bit. The content is there, but the logo image is just huge and white.
Add an ID attribute to each <h2>
with the following values
- news
- sports
- entertainment
In the href=""
for the <a>
in the <header>
add the corresponding values
#news
#sports
#entertainment
Add an <a>
around the following content and href in the <footer>
at the bottom of the <body>
Content
- Email Us
- Call Us
HRef
- mailto:theonion@onion.com
- tel:123456789
- the-onion-articles.pdf
Add this file to your lab5 folder:
CSS
body
font family - Times New Roman, Times, Serif
margin 0
header
background color #275218
color #fff
header>img
This selector will only select direct descendent images of the header
max-width 6rem
margin 1rem
header>h1
display inline-block
margin 1rem 0
Use vertical-align to align the top of the words with the top of the logo, like in the image below.
header>nav>a
background-color #fff
color #275218
text-decoration none
padding 1rem
header>nav
Use padding to add 1rem to the bottom and left, and 0 to the top and right of the navigation.
Hint: If you use four values for padding they are in this order: top | right | bottom | left
Now the links should look like the image above, however they are overlapping on to the main area. Use the display property on the header>nav>a
to fix this. Use one of the three following values to achieve the desired results in the image below:
- block
- inline-block
- inline
header>nav>a:hover
background-color #275218
color #fff
border 1px solid #fff
Now when you hover you will have green buttons with white border, however the buttons jump around when you hover over them. Why is this? This is happening because when an element's width is calculated by the browser does the following:
content+padding+border=element's width
So let's say our content for the first button is 40px and our padding on the nav a is 1rem on both the left and right which would convert to 32px, the math would be the following:
40px + 32px + 0px = 72px - non-hover
40px + 32px + 2px = 74px - hover
To fix this inequality we are going to add a transparent border to the nav>a at 1px on each side.
header>nav>a
border 1px solid transparent
main
background-color #ebebeb
padding 1rem
max-width 60rem
margin 1rem auto
Hint: When adding a width or max-width to an element, you can also take advantage of auto on margin to center the element. The browser in this instance will calculate the following:
browser's width - element's width / 2 = margin on left and right
h2
background-color #275218
color #fff
padding 1rem
margin 0 0 1rem
article
background-color #fff
padding 1rem
margin 1rem 0
Now if you scroll through the web page it looks pretty good, however the images are all different sizes. This is because by default they will display at their actual resolution. So let's fix this.
article>img
max-width 100%
width 30rem
Now they are all the same size, but it would look nice if the text wrapped around the images. So we are going to use the property float on the images to get the text to wrap.
article>img
float left
margin 0 1rem 1rem 0
This will create space on the right and bottom of the image.
However, if you scroll down to the sports and entertainment sections, they look terrible. This is happening because there isn't very much text in two of the articles so the float is causing issues. We will add a class to two of the images to fix this.
In the html document add class="image-only" to the baseball image and the mahersaali image.
article>.image-only
float none
margin 0
width 100%
article>footer
This will only style the footers in the articles. We don't want these styles applied to the footer after the main.
font-style italic
font-weight 900
article>footer span
color #275218
font-size 1.25rem
body>footer
background color #275218
color #fff
padding 1rem
text-align center
body>footer>a
color #fff
margin 1rem
Final Steps
Validate your HTML.
- Navigate to W3C Validator
- Select the validate by file upload tab at the top of the page
Lint your CSS at Jigsaw.w3.org
Now look at GitHub Desktop. You should see all of your files listed out in the left column.
Now you are going to commit your changes.
With all of the files checked. Fill out the Summary field in the bottom left and then click Commit to main.
Committing is staging the files, so they can be pushed to the repository hosted at GitHub.
Now you want to push your changes to the Repository. Now if you access the repository from another computer Lab5 will be there. After you push in the top right of the nav it should say "Fetch Origin" instead of "Push Origin"
Your are Done with Lab5
Are you someone who needs to double check that it worked? If you want to make sure the push was successful click on the "View on GitHub" button from GitHub Desktop. It will open up your repository in the browser. From there you should be able to see all of your files.
...What if I need to make a change after pushing?
So let's say you have already pushed but noticed an error. No worries, this is easy to fix.
In visual studio code make any changes you need to. Once you are done making corrections. Save.
Go back to GitHub Desktop. You should see your changes to the documents listed there.
Fill out the Summary field again. I suggest saying what you fixed. For example: "Fixed paragraph error on Sea-Jellies"
Click "Commit to main"
Click "Push Origin" and you are done.