At the end of this Tutorial you will be able to:
You can view the finished version of the page-9.html sample web page you will create in this Tutorial by clicking the links below. The finished sample will open in a new tab of your web browser.
You will also update your website home web page with a hyperlink to your new sample web page.
In web design, the word panel is used to describe a small rectangular area of a web page. Panels typically contain a sub-heading, a short block of text, an image or a video.
For example, here are four panels from the home page of YouTube. And here are more examples of panels from three sample web projects you will complete later in this course.
In the above examples, most or even all of the web page content consists of panels.
A second use of panels is to highlight a particular item of information within a web page. Such a highlighted panel might contain:
In this Tutorial, you will learn how to use the <div> ... </div> tag to create and design panels in a web page.
You will work with these two files:
You downloaded and unzipped these three files in the previous Tutorial.
Display the page-9.html web page in your Chrome or Mozilla Firefox Developer Edition browser. It should look as shown below.
Open the page-9.html web page and the style-9.css stylesheet files in VS Code
Let's begin by editing the page-9.html file.
Follow these steps to update the stylesheet that controls the appearance of your page-9.html web page.
/* ==== Web browser resets ==== */ * { padding: 0; margin: 0; border: none; box-sizing: border-box } img { display: block; width: 100%; height: auto }
/* === Panel boxes === */ .important-note-box { margin: 54px 0; /* Only top and bottom margins have values */ padding: 16px; /* Same value on all four sides. */ border-style: solid; /* Same value on all four sides. */ border-width: 1px; /* All four borders have equal widths. */ border-color: #000; /* All four borders have same black color. */ }
/* Child sub-heading h3 inside panel boxes */ .important-note-box h3 { font-family: 'Montserrat', sans-serif; /* Overrules h3 font-family value outside panel box. */ font-size: 20px; /* Overrules h3 font-size value outside panel box. */ margin-top: 0; /* Overrules h3 margin-top value outside panel box. */ margin-bottom: 2px; /* Overrules h3 margin-bottom value outside panel box. */ letter-spacing: 1px; /* New - just for h3 headings in panel boxes. */ text-transform: uppercase; /* New - just for h3 headings in panel boxes. */ }Because of the parent-child selector combination of .important-note-box h3, this set of style rules applies only to <h3> sub-headings that are inside a panel box <div> with that class name. No other <h3> sub-headings on the web page are affected.
/* Child paragraph p inside panel boxes */ .important-note-box p { font-size: 18px; /* Overrules p font-size valueoutside panel box. */ line-height: 1.5; /* Overrules p line-height value outside panel box. */ margin-bottom: 0; /* Overrules p margin-bottom value outside panel box. */ }Because of the parent-child selector combination of .important-note-box h3, this set of style rules applies only to paragraphs of text that are inside a panel box <div> with that class name. No other <p> text paragraphs on the web page are affected.
In this final section, you will apply different visual styles to each of the four panel boxes on your page-9.html web page.
<div class="important-note-box box-style-1">
/* === Four different panel box styles === */ /* Panel box style 1 */ .important-note-box.box-style-1 { border-color: #1FA441; background-color: #E4F5E8; /* Drop shadow effect at right and bottom of box */ box-shadow: 8px 10px 8px #888; } .important-note-box.box-style-1 h3 { color: #1FA441 }
/* Panel box style 2 */ .important-note-box.box-style-2 { padding: 16px 0 16px 0; border-width: 8px 0 4px 0; /* Only top and bottom borders have width values */ border-color: #044E6C; } .important-note-box.box-style-2 h3 { color: #044E6C } .important-note-box.box-style-2 p { color: #044E6C }
/* Panel box style 3 */ .important-note-box.box-style-3 { border-width: 0 0 0 20px; /* Only left border has a width value */ border-left-color: #E66465; background-color: #FFE7E8 }
/* Panel box style 4 */ .important-note-box.box-style-4 { padding: 22px; /* Extra padding at edges to make reversed text (light-on-dark) more readable */ border-radius: 10px; border-color: #2c4763; background-color: #1f364d; /* Add rounded effect to all four corners */ } .important-note-box.box-style-4 h3 { color: #9cb3c9 } .important-note-box.box-style-4 p { color: #fff }
Click page-9.html to view a finished sample of this web page in a new tab of your web browser.
Now that you have created and styled the four panels in your new web page, let’s add a hyperlink to this new page to the home page of your web site.
<p><a href="websites/page-9.html">Web Page with Panels</a></p>
Save your index.html web page and view the result in your browser.
After you have finished working with your files, you are ready to upload them to your account on GitHub.
Your web pages will be published at web address similar to the following:
https://username.github.io/index.html
https://username.github.io/websites/page-9.html
It may take a few minutes for your uploaded files to appear on GitHub.
Return to Contents.