Computer Science 318


Fundamentals of Web Design

New Lab 13


Goal

Learn

<table>
    <thead>
        <tr>
            <th>Header Content 1</th>
            <th>Header Content 2</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Body Content 1</td>
            <td>Body Content 2</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
           <td>Footer Content 1</td>
           <td>Footer Content 2</td>
        </tr>
   </tfoot>
</table>

The HTML <table> element represents tabular data that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.

Tables should not be used for formatting a website's layout. They should only be used for displaying data. The exception to this is email code. Emails are built using table tags.

<thead> - defines a set of rows defining the head of the columns for the table.

<tbody> - encapsulates a set of table rows, <tr> elements, indicating that they comprise the body of the table.

<tfoot> - defines a set of rows summarizing the columns for the table.

<tr> - defines a row of cells in a table. The row's cells can then be established using a mix of <td> (data cell) and <th> (header cell) elements.

<th> - defines an individual cell as header of a group of table cells

<td> - defines an individual cell of a table that contains data

<td colspan="8">Span 8 Columns</td>

While there are some attributes you can use to style tables but they are outdated and deprecated. Tables should be styled with CSS.

The only table specific attribute we will be using is colspan. This attribute is used to make a cell span multiple columns.

tr:first-child{
    color:red;
}
tr:last-child{
    color:blue;
}
tr:nth-child(2){
    color:green;
}
tr:nth-child(even){
    color:yellow;
}
tr:nth-child(odd){
    color:pink;
}

The :nth-child() CSS pseudo-class matches elements based on their position among a group of siblings.

:first-child - This selector will select the first element in a group of siblings

:last-child - This selector will select the last element in a group of siblings

:nth-child(n) - This selector will select the number element specified by the integer used for n in a group of siblings. So for example tr:nth-child(3) would select the third row.

:nth-child(even) - This selector will select the even elements in a group of siblings

:nth-child(odd) - This selector will select the odd elements in a group of siblings.

Practice

Experiment Try changing the first <tr> font to red, the last <tr> font to blue, and the third <tr> font to green.

HTML

<table> <thead> <tr> <th>Header Content 1</th> <th>Header Content 2</th> </tr> </thead> <tbody> <tr> <td>Body Content 1</td> <td>Body Content 2</td> </tr> <tr> <td>Body Content 3</td> <td>Body Content 4</td> </tr> <tr> <td>Body Content 5</td> <td>Body Content 6</td> </tr> <tr> <td>Body Content 7</td> <td>Body Content 8</td> </tr> <tr> <td>Body Content 9</td> <td>Body Content 10</td> </tr> <tr> <td>Body Content 11</td> <td>Body Content 12</td> </tr> <tr> <td>Body Content 13</td> <td>Body Content 14</td> </tr> </tbody> </table>

CSS

table{ border:1px solid black; } th, td{ border:1px solid red; } tr:nth-child(even){ color:black; } tr:nth-child(odd){ color:pink; }

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.

With your cs-318 repository selected, Click open in Visual Studio code.

Create a new folder called lab13

Create a new file called index.html in the lab13 folder

Setup your HTML files

Create your stylesheet

Link your stylesheet to the HTML

Change Document in the <title> element to "Lord of the Rings Characters"

HTML

Add a header and a main in the body

In the header add a h1 with the content "The Lord of the Rings"

Add a nav after the h1

In the nav add three anchors. You will add in the jump links for the hrefs later.

Add three sections

Section 1

h2 - Middle Earth

p - Middle-earth was a large continent of Arda, situated between Aman to the West (across Belegaer), and the Land of the Sun to the East (across the East Sea).

p - Most of the history of Arda takes place in Middle-earth, and it was where the Children of Ilúvatar came into being; Elves and Men, as well as the Dwarves.

img -

Lab 13 - Middle Earth Map

Lab 13 - First section html setup

Section 2

Add a <table> element. Every element from here on down will be in the table.

Add a <thead>

In the <thead> add each bullet point as a <th>

Then add a <tr> around the first <th> and a second <tr> around the rest of the <th> in the <thead>

Add a <tbody>

In the <tbody> add the following 13 times:

Content for the 13 <tr> in the <tbody>

Smeagol

Frodo

Samwise

Gandalf

Aragon

Legolas

Gimli

Merry

Peregrin

Boromir

Sauron

Saruman

Bilbo

Lab 12 html setup

Section 3

h2 - Books

three divs. In each div add a h3 and image tag

Add an id attribute to each section and then link the anchors in the navigation to those ids

CSS

body

margin 0

background color black

font color antiquewhite

header

background image

The Eye of Sauron

background position center

background size 120%

Lab 13 header background image

header

height 70vh

Use display flex and flex properties to move the h1 and nav to the bottom center of the header

Lab 13 header with display flex and properties

HTML

Add this font link to your head

<link rel="stylesheet" href="https://use.typekit.net/lgb7vqg.css">

Add a <span> around "of the" in the h1

CSS

header

font-family: "p22-elven", sans-serif;

h1 span

display block

font size 2rem

h1

font size 5rem

font color gold

Now use position absolute to move the h1 to the right of the eye of Sauron. Remember you need to add position relative to the parent container and use top, left, right, or bottom to move the h1. I recommend using a percentage value for the left or right so it will move when the browser is resized.

Lab 13 - Lord of the Rings h1 positioned using absolute

nav a

font color gold

font size 2rem

text decoration none

nav a

font color darkorange

text decoration underline

Lab 13 navigation link styles

nav

Add the following background gradient

background: #000;
background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 80%);

padding 1rem 0

width 100vw

Use Flexbox properties to make the navigation link spread out evenly across the page.

Lab 13 navigation setup with Flexbox properties

img

max-width 100%

section

max-width 60rem

margin 1rem auto

Lab 13 image and section styles

table

border-spacing 0

add background image

Lab 13 table background

add background size cover

Add the following CSS to create a jagged edge around the table.

color:rgb(18,3,0);
    padding: 2rem;
	clip-path: shape(from 25.76px 11.26px,curve to calc(1.72% + 28.97px) 14.5px with calc(0% + 30px) 1px,smooth to calc(5.17% + 26.9px) 21px,smooth to calc(8.62% + 24.83px) 9.5px,smooth to calc(12.07% + 22.76px) 3.5px,smooth to calc(15.52% + 20.69px) 14px,smooth to calc(18.97% + 18.62px) 17px,smooth to calc(22.41% + 16.55px) 13.5px,smooth to calc(25.86% + 14.48px) 10.5px,smooth to calc(29.31% + 12.41px) 3.5px,smooth to calc(32.76% + 10.34px) 15.5px,smooth to calc(36.21% + 8.28px) 18px,smooth to calc(39.66% + 6.21px) 14px,smooth to calc(43.1% + 4.14px) 14px,smooth to calc(46.55% + 2.07px) 13.5px,smooth to calc(50% + 0px) 13.5px,smooth to calc(53.45% + -2.07px) 16.5px,smooth to calc(56.9% + -4.14px) 23.5px,smooth to calc(60.34% + -6.21px) 25.5px,smooth to calc(63.79% + -8.28px) 27px,smooth to calc(67.24% + -10.34px) 16px,smooth to calc(70.69% + -12.41px) 6px,smooth to calc(74.14% + -14.48px) 16px,smooth to calc(77.59% + -16.55px) 25px,smooth to calc(81.03% + -18.62px) 18px,smooth to calc(84.48% + -20.69px) 16px,smooth to calc(87.93% + -22.76px) 25.5px,smooth to calc(91.38% + -24.83px) 26.5px,smooth to calc(94.83% + -26.9px) 23px,smooth to calc(98.28% + -28.97px) 18.5px,smooth to calc(100% - 27.17px) 19.17px,smooth to calc(100% - 15.17px) 27.17px,smooth to calc(100% - 3.5px) calc(0.53% + 29.68px),smooth to calc(100% - 6.5px) calc(1.58% + 29.05px),smooth to calc(100% - 8px) calc(2.63% + 28.42px),smooth to calc(100% - 3.5px) calc(3.68% + 27.79px),smooth to calc(100% - 10.5px) calc(4.74% + 27.16px),smooth to calc(100% - 12px) calc(5.79% + 26.53px),smooth to calc(100% - 12.5px) calc(6.84% + 25.89px),smooth to calc(100% - 14px) calc(7.89% + 25.26px),smooth to calc(100% - 11px) calc(8.95% + 24.63px),smooth to calc(100% - 13px) calc(10% + 24.00px),smooth to calc(100% - 9px) calc(11.05% + 23.37px),smooth to calc(100% - 13.5px) calc(12.11% + 22.74px),smooth to calc(100% - 13.5px) calc(13.16% + 22.11px),smooth to calc(100% - 7px) calc(14.21% + 21.47px),smooth to calc(100% - 7.5px) calc(15.26% + 20.84px),smooth to calc(100% - 16px) calc(16.32% + 20.21px),smooth to calc(100% - 21.5px) calc(17.37% + 19.58px),smooth to calc(100% - 12px) calc(18.42% + 18.95px),smooth to calc(100% - 5.5px) calc(19.47% + 18.32px),smooth to calc(100% - 11.5px) calc(20.53% + 17.68px),smooth to calc(100% - 22.5px) calc(21.58% + 17.05px),smooth to calc(100% - 28px) calc(22.63% + 16.42px),smooth to calc(100% - 27px) calc(23.68% + 15.79px),smooth to calc(100% - 17px) calc(24.74% + 15.16px),smooth to calc(100% - 8.5px) calc(25.79% + 14.53px),smooth to calc(100% - 5px) calc(26.84% + 13.89px),smooth to calc(100% - 13px) calc(27.89% + 13.26px),smooth to calc(100% - 11.5px) calc(28.95% + 12.63px),smooth to calc(100% - 12.5px) calc(30% + 12.00px),smooth to calc(100% - 23px) calc(31.05% + 11.37px),smooth to calc(100% - 14px) calc(32.11% + 10.74px),smooth to calc(100% - 9px) calc(33.16% + 10.11px),smooth to calc(100% - 11px) calc(34.21% + 9.47px),smooth to calc(100% - 16px) calc(35.26% + 8.84px),smooth to calc(100% - 21px) calc(36.32% + 8.21px),smooth to calc(100% - 12.5px) calc(37.37% + 7.58px),smooth to calc(100% - 13.5px) calc(38.42% + 6.95px),smooth to calc(100% - 23.5px) calc(39.47% + 6.32px),smooth to calc(100% - 26.5px) calc(40.53% + 5.68px),smooth to calc(100% - 24px) calc(41.58% + 5.05px),smooth to calc(100% - 20.5px) calc(42.63% + 4.42px),smooth to calc(100% - 12px) calc(43.68% + 3.79px),smooth to calc(100% - 15px) calc(44.74% + 3.16px),smooth to calc(100% - 20.5px) calc(45.79% + 2.53px),smooth to calc(100% - 9px) calc(46.84% + 1.89px),smooth to calc(100% - 7px) calc(47.89% + 1.26px),smooth to calc(100% - 8px) calc(48.95% + 0.63px),smooth to calc(100% - 13px) calc(50% + 0.00px),smooth to calc(100% - 17.5px) calc(51.05% + -0.63px),smooth to calc(100% - 21.5px) calc(52.11% + -1.26px),smooth to calc(100% - 20px) calc(53.16% + -1.89px),smooth to calc(100% - 12.5px) calc(54.21% + -2.53px),smooth to calc(100% - 12px) calc(55.26% + -3.16px),smooth to calc(100% - 13px) calc(56.32% + -3.79px),smooth to calc(100% - 21px) calc(57.37% + -4.42px),smooth to calc(100% - 28px) calc(58.42% + -5.05px),smooth to calc(100% - 27px) calc(59.47% + -5.68px),smooth to calc(100% - 22px) calc(60.53% + -6.32px),smooth to calc(100% - 12px) calc(61.58% + -6.95px),smooth to calc(100% - 15.5px) calc(62.63% + -7.58px),smooth to calc(100% - 16px) calc(63.68% + -8.21px),smooth to calc(100% - 13px) calc(64.74% + -8.84px),smooth to calc(100% - 23.5px) calc(65.79% + -9.47px),smooth to calc(100% - 23.5px) calc(66.84% + -10.11px),smooth to calc(100% - 10px) calc(67.89% + -10.74px),smooth to calc(100% - 15.5px) calc(68.95% + -11.37px),smooth to calc(100% - 19px) calc(70% + -12.00px),smooth to calc(100% - 4.5px) calc(71.05% + -12.63px),smooth to calc(100% - 8.5px) calc(72.11% + -13.26px),smooth to calc(100% - 15.5px) calc(73.16% + -13.89px),smooth to calc(100% - 16px) calc(74.21% + -14.53px),smooth to calc(100% - 21.5px) calc(75.26% + -15.16px),smooth to calc(100% - 28px) calc(76.32% + -15.79px),smooth to calc(100% - 22.5px) calc(77.37% + -16.42px),smooth to calc(100% - 17.5px) calc(78.42% + -17.05px),smooth to calc(100% - 19px) calc(79.47% + -17.68px),smooth to calc(100% - 10.5px) calc(80.53% + -18.32px),smooth to calc(100% - 15.5px) calc(81.58% + -18.95px),smooth to calc(100% - 20px) calc(82.63% + -19.58px),smooth to calc(100% - 7px) calc(83.68% + -20.21px),smooth to calc(100% - 14px) calc(84.74% + -20.84px),smooth to calc(100% - 25.5px) calc(85.79% + -21.47px),smooth to calc(100% - 22px) calc(86.84% + -22.11px),smooth to calc(100% - 12px) calc(87.89% + -22.74px),smooth to calc(100% - 13px) calc(88.95% + -23.37px),smooth to calc(100% - 17.5px) calc(90% + -24.00px),smooth to calc(100% - 13.5px) calc(91.05% + -24.63px),smooth to calc(100% - 14px) calc(92.11% + -25.26px),smooth to calc(100% - 9.5px) calc(93.16% + -25.89px),smooth to calc(100% - 14px) calc(94.21% + -26.53px),smooth to calc(100% - 12px) calc(95.26% + -27.16px),smooth to calc(100% - 7px) calc(96.32% + -27.79px),smooth to calc(100% - 10px) calc(97.37% + -28.42px),smooth to calc(100% - 4.5px) calc(98.42% + -29.05px),smooth to calc(100% - 7.5px) calc(99.47% + -29.68px),smooth to calc(100% - 13.22px) calc(100% - 22.22px),smooth to calc(100% - 22.22px) calc(100% - 7.22px),smooth to calc(98.28% - 28.97px) calc(100% - 12px),smooth to calc(94.83% - 26.9px) calc(100% - 14px),smooth to calc(91.38% - 24.83px) calc(100% - 4.5px),smooth to calc(87.93% - 22.76px) calc(100% - 17.5px),smooth to calc(84.48% - 20.69px) calc(100% - 17.5px),smooth to calc(81.03% - 18.62px) calc(100% - 17px),smooth to calc(77.59% - 16.55px) calc(100% - 18px),smooth to calc(74.14% - 14.48px) calc(100% - 11.5px),smooth to calc(70.69% - 12.41px) calc(100% - 11.5px),smooth to calc(67.24% - 10.34px) calc(100% - 16.5px),smooth to calc(63.79% - 8.28px) calc(100% - 23px),smooth to calc(60.34% - 6.21px) calc(100% - 20.5px),smooth to calc(56.9% - 4.14px) calc(100% - 23px),smooth to calc(53.45% - 2.07px) calc(100% - 21.5px),smooth to calc(50% - 0px) calc(100% - 19.5px),smooth to calc(46.55% - -2.07px) calc(100% - 22.5px),smooth to calc(43.1% - -4.14px) calc(100% - 19.5px),smooth to calc(39.66% - -6.21px) calc(100% - 11px),smooth to calc(36.21% - -8.28px) calc(100% - 6px),smooth to calc(32.76% - -10.34px) calc(100% - 4px),smooth to calc(29.31% - -12.41px) calc(100% - 11.5px),smooth to calc(25.86% - -14.48px) calc(100% - 16px),smooth to calc(22.41% - -16.55px) calc(100% - 11.5px),smooth to calc(18.97% - -18.62px) calc(100% - 6.5px),smooth to calc(15.52% - -20.69px) calc(100% - 6px),smooth to calc(12.07% - -22.76px) calc(100% - 11.5px),smooth to calc(8.62% - -24.83px) calc(100% - 9.5px),smooth to calc(5.17% - -26.9px) calc(100% - 7px),smooth to calc(1.72% - -28.97px) calc(100% - 4.5px),smooth to 20.81px calc(100% - 6.31px),smooth to 14.81px calc(100% - 20.81px),smooth to 10px calc(99.47% - 29.68px),smooth to 1.5px calc(98.42% - 29.05px),smooth to 12.5px calc(97.37% - 28.42px),smooth to 14.5px calc(96.32% - 27.79px),smooth to 14px calc(95.26% - 27.16px),smooth to 19.5px calc(94.21% - 26.53px),smooth to 18px calc(93.16% - 25.89px),smooth to 23px calc(92.11% - 25.26px),smooth to 18.5px calc(91.05% - 24.63px),smooth to 5.5px calc(90% - 24px),smooth to 1px calc(88.95% - 23.37px),smooth to 12.5px calc(87.89% - 22.74px),smooth to 20px calc(86.84% - 22.11px),smooth to 23.5px calc(85.79% - 21.47px),smooth to 22px calc(84.74% - 20.84px),smooth to 14px calc(83.68% - 20.21px),smooth to 7.5px calc(82.63% - 19.58px),smooth to 15px calc(81.58% - 18.95px),smooth to 27.5px calc(80.53% - 18.32px),smooth to 13px calc(79.47% - 17.68px),smooth to 0.5px calc(78.42% - 17.05px),smooth to 7px calc(77.37% - 16.42px),smooth to 10.5px calc(76.32% - 15.79px),smooth to 4.5px calc(75.26% - 15.16px),smooth to 6px calc(74.21% - 14.53px),smooth to 16.5px calc(73.16% - 13.89px),smooth to 21px calc(72.11% - 13.26px),smooth to 18px calc(71.05% - 12.63px),smooth to 22px calc(70% - 12px),smooth to 23px calc(68.95% - 11.37px),smooth to 10.5px calc(67.89% - 10.74px),smooth to 10px calc(66.84% - 10.11px),smooth to 19px calc(65.79% - 9.47px),smooth to 15px calc(64.74% - 8.84px),smooth to 15px calc(63.68% - 8.21px),smooth to 23px calc(62.63% - 7.58px),smooth to 20px calc(61.58% - 6.95px),smooth to 10px calc(60.53% - 6.32px),smooth to 12.5px calc(59.47% - 5.68px),smooth to 10.5px calc(58.42% - 5.05px),smooth to 3.5px calc(57.37% - 4.42px),smooth to 6.5px calc(56.32% - 3.79px),smooth to 4.5px calc(55.26% - 3.16px),smooth to 5px calc(54.21% - 2.53px),smooth to 9px calc(53.16% - 1.89px),smooth to 11px calc(52.11% - 1.26px),smooth to 10px calc(51.05% - 0.63px),smooth to 13px calc(50% - 0px),smooth to 10.5px calc(48.95% - -0.63px),smooth to 6px calc(47.89% - -1.26px),smooth to 9px calc(46.84% - -1.89px),smooth to 17.5px calc(45.79% - -2.53px),smooth to 19px calc(44.74% - -3.16px),smooth to 20.5px calc(43.68% - -3.79px),smooth to 24px calc(42.63% - -4.42px),smooth to 19px calc(41.58% - -5.05px),smooth to 13px calc(40.53% - -5.68px),smooth to 5.5px calc(39.47% - -6.32px),smooth to 14px calc(38.42% - -6.95px),smooth to 22px calc(37.37% - -7.58px),smooth to 20.5px calc(36.32% - -8.21px),smooth to 13.5px calc(35.26% - -8.84px),smooth to 17px calc(34.21% - -9.47px),smooth to 15.5px calc(33.16% - -10.11px),smooth to 12.5px calc(32.11% - -10.74px),smooth to 13px calc(31.05% - -11.37px),smooth to 8px calc(30% - -12px),smooth to 10px calc(28.95% - -12.63px),smooth to 18.5px calc(27.89% - -13.26px),smooth to 21.5px calc(26.84% - -13.89px),smooth to 18px calc(25.79% - -14.53px),smooth to 20px calc(24.74% - -15.16px),smooth to 18.5px calc(23.68% - -15.79px),smooth to 9.5px calc(22.63% - -16.42px),smooth to 12.5px calc(21.58% - -17.05px),smooth to 24.5px calc(20.53% - -17.68px),smooth to 26px calc(19.47% - -18.32px),smooth to 23.5px calc(18.42% - -18.95px),smooth to 17.5px calc(17.37% - -19.58px),smooth to 22.5px calc(16.32% - -20.21px),smooth to 28px calc(15.26% - -20.84px),smooth to 13.5px calc(14.21% - -21.47px),smooth to 3.5px calc(13.16% - -22.11px),smooth to 14px calc(12.11% - -22.74px),smooth to 19.5px calc(11.05% - -23.37px),smooth to 22.5px calc(10% - -24px),smooth to 26.5px calc(8.95% - -24.63px),smooth to 16px calc(7.89% - -25.26px),smooth to 3.5px calc(6.84% - -25.89px),smooth to 5.5px calc(5.79% - -26.53px),smooth to 16px calc(4.74% - -27.16px),smooth to 17px calc(3.68% - -27.79px),smooth to 8.5px calc(2.63% - -28.42px),smooth to 8px calc(1.58% - -29.05px),smooth to 17.5px calc(0.53% - -29.68px),smooth to 22.76px 25.76px,smooth to 25.76px 11.26px);

Lab 13 table CSS background added

thead tr:first-child

font size 2rem

td,th

padding .5rem

vertical-align top.
This will move the content in the cells to the top of the cell

table img

max-width unset

width 10rem

Lab 13 table with some CSS properties

tbody tr:nth-child(odd)

Add background color rgba(244, 235, 192, 0.303)

tbody tr:hover

Add background color background-color: rgba(239, 229, 203, 0.5);

Lab 13 table CSS with pseudo nth-childs