In: Computer Science
Summary
Figure 3–79 shows an example page containing two applications of floating objects. In the first line of Lincoln’s second inaugural speech a drop capital is created by floating the first letter of the first paragraph next to the surrounding text. The text of the speech is wrapped around the image of Lincoln using an irregular line wrap. This effect is created by cutting the Lincoln image into separate strips which are floated and stacked on top of each other. In this Coding Challenge you will explore how to create both effects.
Figure 3-79
Do the following:
1. Open the files code3-1.html and code3-1_float.css and in the comment section enter your name (First + Last) and the date (MM/DD/YYYY) into the Author: and Date: fields of the file.
2. Go to the code3-1.html file in your editor. Within the head section insert a link element linking the page to the code3-1_float.css style sheet file. Take some time to study the content of the page.
3.lOpen the file code3-1_float.css, and for all img elements create a style rule to set the height of the image to 3.3em. Float all img elements on the right margin, but only when the right margin is first cleared of any floats. (Hint: clear: right).
4. To create a drop cap insert a style rule for the selector p:first-of-type::first-letter and add the following styles:
5. Display the first line of the speech in small caps by adding a style rule for the selector p:first-of-type::first-line that changes the font variant to small-caps and the font size to 1.4em.
6. Open the page in the browser preview and verify the layout of the page resembles that shown in Figure 3-79.
Code 3-1.HTML to be edited:
<!doctype html>
<html lang="en">
<head>
<!--
New Perspectives on HTML5 and CSS3, 8th Edition
Tutorial 3
Coding Challenge 1
Author:
Date:
Filename: code3-1.html
-->
<meta charset="utf-8">
<title>Coding Challenge 3-1</title>
<link href="code3-1.css" rel="stylesheet" />
</head>
<body>
<h1>Lincoln's Second Inaugural</h1>
<p>The Almighty has his own purposes. "Woe unto the world because of offenses! For
<img src="lincoln01.png" alt="" />
<img src="lincoln02.png" alt="" />
<img src="lincoln03.png" alt="" />
<img src="lincoln04.png" alt="" />
<img src="lincoln05.png" alt="" />
<img src="lincoln06.png" alt="" />
<img src="lincoln07.png" alt="" />
<img src="lincoln08.png" alt="" />
<img src="lincoln09.png" alt="" />
<img src="lincoln10.png" alt="" />
it must needs be that offenses come; but woe to that man by whom the offense
cometh." If we shall suppose that American slavery is one of those offenses which,
in the providence of God, must needs come, but which, having continued through his
appointed time, he now wills to remove, and that he gives to both North and South
this terrible war, as the woe due to those by whom the offense came, shall we discern
therein any departure from those divine attributes which the believers in a living
God always ascribe to him?
</p>
<p>Fondly do we hope — fervently do we pray — that this
mighty scourge of war may speedily pass away. Yet, if God wills that it continue
until all the wealth piled by the bondsman's two hundred and fifty years of unrequited
toil shall be sunk, and until every drop of blood drawn by the lash shall be paid by
another drawn with the sword, as was said three thousand years ago, so still it must
be said, "The judgments of the Lord are true and righteous altogether."
</p>
<p>With malice toward none; with charity for all; with firmness in the right, as God
gives us to see the right, let us strive on to finish the work we are in; to bind up
the nation's wounds; to care for him who shall have borne the battle, and for his
widow, and his orphan — to do all which may achieve and cherish a just and lasting peace
among ourselves, and with all nations.
</p>
</body>
</html>
Code 3-1.css to be edited:
@charset "utf-8";
/*
New Perspectives on HTML5 and CSS3, 8th Edition
Tutorial 3
Coding Challenge 1
Author:
Date:
Filename: code3-1.css
*/
body {
width: 900px;
margin: 20px auto;
font-family: Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", "serif";
font-size: 1.25em;
padding-bottom: 30px;
}
h1 {
font-size: 2.2em;
text-align: center;
}
Code 3-1_float.css to be edited:
@charset "utf-8";
/*
New Perspectives on HTML5 and CSS3, 8th Edition
Tutorial 3
Coding Challenge 1
Author:
Date:
Filename: code3-1_float.css
*/
Images being used:
Okay So we will approach this problem step by step.
Before we begin, there are some things which i'd like to let you know
- Everything that i insert in your code file would be in Bold so that you can differentiate easily between the given question and the answer.
- Now in HTML, we write our comment as <!-- your text --> . So according to the problem, you have to write your name and date in the comment section of the HTML and CSS files.
- link tag is used to link html and css files. All the other tags used in the changes depicts the same such as line-height is for line height and font-size is for font size. px stands for pixels and it is not screen relative while em is screen relative.
now, here's my solution
Code 3-1.html :
<!doctype html>
<html lang="en">
<head>
<!--
New Perspectives on HTML5 and CSS3, 8th Edition
Tutorial 3
Coding Challenge 1
Author:
Date:
Filename: code3-1.html
-->
<meta charset="utf-8">
<title>Coding Challenge 3-1</title>
<link href="code3-1.css" rel="stylesheet" />
<link href="code3-1_float.css" rel="stylesheet" />
</head>
<body>
<h1>Lincoln's Second Inaugural</h1>
<p>The Almighty has his own purposes. "Woe unto the world because of offenses! For
<img src="lincoln01.png" />
<img src="lincoln02.png" />
<img src="lincoln03.png" />
<img src="lincoln04.png" />
<img src="lincoln05.png" />
<img src="lincoln06.png" />
<img src="lincoln07.png" />
<img src="lincoln08.png" />
<img src="lincoln09.png" />
<img src="lincoln10.png" />
it must needs be that offenses come; but woe to that man by whom the offense
cometh." If we shall suppose that American slavery is one of those offenses which,
in the providence of God, must needs come, but which, having continued through his
appointed time, he now wills to remove, and that he gives to both North and South
this terrible war, as the woe due to those by whom the offense came, shall we discern
therein any departure from those divine attributes which the believers in a living
God always ascribe to him?
</p>
<p>Fondly do we hope — fervently do we pray — that this
mighty scourge of war may speedily pass away. Yet, if God wills that it continue
until all the wealth piled by the bondsman's two hundred and fifty years of unrequited
toil shall be sunk, and until every drop of blood drawn by the lash shall be paid by
another drawn with the sword, as was said three thousand years ago, so still it must
be said, "The judgments of the Lord are true and righteous altogether."
</p>
<p>With malice toward none; with charity for all; with firmness in the right, as God
gives us to see the right, let us strive on to finish the work we are in; to bind up
the nation's wounds; to care for him who shall have borne the battle, and for his
widow, and his orphan — to do all which may achieve and cherish a just and lasting peace
among ourselves, and with all nations.
</p>
</body>
</html>
Code 3-1.css to be edited:
@charset "utf-8";
/*
New Perspectives on HTML5 and CSS3, 8th Edition
Tutorial 3
Coding Challenge 1
Author:
Date:
Filename: code3-1.css
*/
body {
width: 900px;
margin: 20px auto;
font-family: Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", "serif";
font-size: 1.25em;
padding-bottom: 30px;
}
h1 {
font-size: 2.2em;
text-align: center;
}
p:first-of-type::first-letter{
float:left;
font-size: 4 em;
line-height: 0.8em;
margin-right: 0.1em;
padding-right: 0.1em;
padding-bottom: 0.2 em;
}
p:first-of-type::first-line{
font-variant: small-caps;
font-size: 1.4 em;
}
Code 3-1_float.css:
@charset "utf-8";
/*
New Perspectives on HTML5 and CSS3, 8th Edition
Tutorial 3
Coding Challenge 1
Author:
Date:
Filename: code3-1_float.css
*/
img{
height :3.3em;
float : right;
}
h1,p{
clear:right;
}
These are all the changes which should be made in given files other than your name and date.
Please comment and let me know if you have any doubts.
Thank you.
Have a good day.