Professional Documents
Culture Documents
Answer
Answer
When an element is contained inside another element, it is
considered the child of that element. The child element is said
to be nested inside of the parent element.e.g. <p> in <body>
The relationship between elements and their ancestor and
descendent elements is known as hierarchy.
<body>-grandfather,<div>-father,<h1>,<p>-child(siblings)
In html there are 6 types of headings<h1><h2>…<h6>
Is it correct to say that the <body> element is nested within the <html> element?
Answer
That is correct! The <html> tag is the root element of every page and it should always
have <head> and <body> child elements. The <head> and <body> elements are
siblings to each other and children to the <html> parent.
In steps 1 and 2 of this exercise, both <p> elements display in the same exact way. As
it doesn’t seem like anything special happened here, what is the point of nesting the
<p> element in a <div> element?
Answer
In this case, this is done purely for demonstrative purpose. In the future you will find
that <div> elements are often used to group related content. This can serve to give a
page some added structure and to allow for more modular styling.
This exercise 96 says that child elements can inherit from their parents. What sorts of
things can child elements inherit from their parents?
Answer
When you dive into our CSS course you will learn that child elements inherit most of
their styling from their parent elements. In other words, most styles cascade down
from parents to children.
div (short for division) allows us to divide our page into different sections, to position
this sections. Divs are very useful. The change might not be the most visual one,
doesn’t make it less useful.
<h1>MEDHA</h1>
ME
DH
A
<body> Whats
<p> Whats up, doc?</p> up,
doc?
</body>
<body>
<h1>Hello World</h1>
<div>
<p>This paragraph is a child of the div element and a grandchil
d of the body element</p>
</div>
</body>
<div id="intro">
<h1>Introduction</h1></div>
<video src="https://content.codecademy.com/courses/freelance-
1/unit-1/lesson-2/htmlcss1-vid_brown-bear.mp4">
</video>
1. <span> contains short pieces of text or other HTML. They are used
to separate small pieces of content that are on the same line as
other content.
It is like the <p> tag in that it is intended for displaying text, but unlike it in that it
does not start a new line. (in other words, it is inline)
<span> is mainly used to help you once you get to CSS so that you can style one part
of a paragraph differently than the rest.
It is also used as an element that is only there to let you style the contents.
I hope that answers your question!
HTML stands for HyperText Markup Language and is used to create the structure and
content of a webpage.
Most HTML elements contain opening and closing tags with raw text or other HTML tags
between them.
HTML elements can be nested inside other elements. The enclosed element is the child of
the enclosing parent element.
Any visible content should be placed within the opening and closing <body> tags.
Headings and sub-headings, <h1> to <h6> tags, are used to enlarge text.
<p>, <span> and <div> tags specify text or blocks.
The <em> and <strong> tags are used to emphasize text.
Line breaks are created with the <br> tag.
Ordered lists (<ol>) are numbered and unordered lists (<ul>) are bulleted.
Images (<img>) and videos (<video>) can be added by linking to an existing source.
<ul><li><a href="#introduction">Introduction<
/a></li>
<li><a href="#habitat">Habitat</a></li>
<li><a href="#media">Media</a></li>
</ul>
2. The <head> element contains the metadata for a web page. Metadata
is information about the page that isn’t displayed directly on
the web page.
<!DOCTYPE html>
<html>
<head>
<body>
<h1>The Brown Bear</h1>
<div id="introduction">
<h2>About Brown Bears</h2>
<p>The brown bear (<em>Ursus arctos</em>) is native to parts of n
orthern Eurasia and North America. Its conservation status is currently
<strong>Least Concern</strong>.<br /><br /> There are many subspecies w
ithin the brown bear species, including the
Atlas bear and the Himalayan brown bear.</p>
<h3>Species</h3>
<ul>
<li>Arctos</li>
<li>Collarus</li>
<li>Horribilis</li>
<li>Nelsoni (extinct)</li>
</ul>
<h3>Features</h3>
<p>Brown bears are not always completely brown. Some can be reddi
sh or yellowish. They have very large, curved claws and huge paws. Male
brown bears are often 30% larger than female brown bears. They can rang
e from 5 feet to 9 feet from head to toe.</p>
</div>
<div id="habitat">
<h2>Habitat</h2>
<h3>Countries with Large Brown Bear Populations</h3>
<ol>
<li>Russia</li>
<li>United States</li>
<li>Canada</li>
</ol>
<h3>Countries with Small Brown Bear Populations</h3>
<p>Some countries with smaller brown bear populations include Arm
enia, Belarus, Bulgaria, China, Finland, France, Greece, India, Japan,
Nepal, Poland, Romania, Slovenia, Turkmenistan, and Uzbekistan.</p>
</div>
<div id="media">
<h2>Media</h2>
<img src="https://s3.amazonaws.com/codecademy-
content/courses/web-101/web101-image_brownbear.jpg" />
<video src="https://s3.amazonaws.com/codecademy-
content/courses/freelance-1/unit-1/lesson-2/htmlcss1-vid_brown-
bear.mp4" width="320" height="240" controls>Video not supported</video>
</div>
</body>
</head>
</html>
<body>
<p>Paragraph 1</p>
<div>
<p>Paragraph 2</p>
</div></body>
6. Example of identation:
<body>
<h1>Whitespace</h1>
<div>
<p>Whitespace and indentation make html documents easier to read.</
p>
</div>
</body>
7. Comments begin with <!-- and end with -->. Any characters in
between will be ignored by your browser.
8.
<title>Favorite Quotes</title>
<!-- <p> Test Code </p> -->
</head>
The first step in entering data into the table is to add rows using the table row
element: <tr><table>
<tr>
</tr>
<tr>
</tr></table>
<table>
<tr>
</tr>
<tr>
<td>Adam’s Greenworks</td>
<td>14</td>
<td>Package Items</td>
</tr>
</table>
<table>
<tr>
<th>Company Name</th>Number of Items to Ship<th></th><th>Next Act
ion</th>
</tr>
<tr>
<td>Adam’s Greenworks</td>
<td>14</td>
<td>Package Items</td>
</tr>
</table>
table, td {
border: 1px solid black;
}
<table>
<tr>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
</tr>
<tr>
<td colspan="2">Out of Town</td>
<td>Back in Town</td>
</tr></table>
In the example above, the data Out of Town spans the Monday and Tuesday table
headings using the value 2 (two columns). The data Back in Town appear only under
the Wednesday heading.
<table>
<tr> <!-- Row 1 -->
<th></th>
<th>Saturday</th>
<th>Sunday</th>
</tr>
<tr> <!-- Row 2 -->
<th>Morning</th>
<td rowspan="2">Work</td>
<td rowspan="3">Relax</td>
</tr>
<tr> <!-- Row 3 -->
<th>Afternoon</th>
</tr>
<tr> <!-- Row 4 -->
<th>Evening</th>
<td>Dinner</td>
</tr></table>
Long tables can be sectioned off using the table body element: <tbody>.
The <tbody> element should contain all of the table’s data, excluding the table
headings
<table>
<tbody>
<thead>
<tr>
<th>Company Name</th>Number of Items to Ship<th></th><th>Next Act
ion</th>
</tr>
</thead>
<tr>
The bottom part of a long table can also be sectioned off using the
<tfoot> element.
<tfoot>
<td>Total</td>
<td>28</td>
</tfoot>
</table>
<!DOCTYPE html>
<html>
<head>
<title>Ship To It - Company Packing List</title>
<table>
<tbody>
<thead>
<tr>
<th>Company Name</th>Number of Items to Ship<th></th><th>Next Act
ion</th>
</tr>
</thead>
<tr>
<td colspan="2">Adam’s Greenworks</td>
<td rowspan="2">14</td>
<td>Package Items</td>
</tr>
<tr>
<td>Davie's Burgers</td>
<td>2</td>
<td>Send Invoice</td>
</tr>
<tr>
<td>Baker's Bike Shop</td>
<td>3</td>
<td>Send Invoice</td>
</tr>
<tr>
<td>Miss Sally's Southern</td>
<td>4</td>
<td>Ship</td>
</tr>
<tr>
<td>Summit Resort Rentals</td>
<td>4</td>
<td>Ship</td>
</tr>
<tr>
<td>Strike Fitness</td>
<td>1</td>
<td>Enter Order</td>
</tr>
</tbody>
<tfoot>
<td>Total</td>
<td>28</td>
</tfoot>
</table>
</html>
<form action="/practice.html" method="POST">
<h1>Creating a form</h1>
<p>Looks like you want to learn how to create an HTML form. Well,
the best way to learn is to play around with it.</p>
</form>
<section class="patties">
<label for="amount">How man
y patties would you like?</label>
<!--Add your code below-->
<input id="amount" name="am
ount" type="number" step="1">
</section>
</form>
Checkbox : <section class="toppings">
<span>What toppings would y
ou like?</span>
<br>
<!--Add your code below for
the first checkbox-->
<input id="lettuce" name="t
opping" type="checkbox" value="lettuc
e">
<label for="lettuce">Lettuc
e</label>
<!--Add your code below for
the second checkbox-->
<input id="tomato" name="to
pping" type="checkbox" value="tomato"
>
<label for="tomato">Tomato<
/label>
<!--Add your code below for
the third checkbox-->
<input id="onion" name="top
ping" type="checkbox" value="onion">
<label for="onion">Onion</l
abel>
</section>
</form>
<section class="sauce-selection">
<label for="sauce">What typ
e of sauce would you like?</label>
<input list="sauces" id="sa
uce" name="sauce">
<!--Add your code below-->
<datalist id="sauces">
<option value="ketchup"></option>
<option value="mayo"></option>
<option value="Mexician"></option
>
</datalist>
</section>
Checkbox:
Form: whole code:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Rubik" re
l="stylesheet">
<title>Forms Review</title>
</head>
<body>
<section id="overlay">
<img src="https://s3.amazonaws.com/codecademy-
content/courses/web-101/unit-6/htmlcss1-img_burger-logo.svg" al
t="Davie's Burgers Logo" id="logo">
<hr>
<form action="submission.html" method="POST">
<h1>Create a burger!</h1>
<section class="protein">
<label for="patty">What type of protein would you like?
</label>
<input type="text" name="patty" id="patty">
</section>
<hr>
<section class="patties">
<label for="amount">How many patties would you like?</label>
<input type="number" name="amount" id="amount">
</section>
<hr>
<section class="cooked">
<label for="doneness">How do you want your patty cooked</labe
l>
<br>
<span>Rare</span>
<input type="range" name="doneness" id="doneness" value="3" m
in="1" max="5">
<span>Well-Done</span>
</section>
<hr>
<section class="toppings">
<span>What toppings would you like?</span>
<br>
<input type="checkbox" name="topping" id="lettuce" value="let
tuce">
<label for="lettuce">Lettuce</label>
<input type="checkbox" name="topping" id="tomato" value="toma
to">
<label for="tomato">Tomato</label>
<input type="checkbox" name="topping" id="onion" value="onion
">
<label for="onion">Onion</label>
</section>
<hr>
<section class="cheesy">
<span>Would you like to add cheese?</span>
<br>
<input type="radio" name="cheese" id="yes" value="yes">
<label for="yes">Yes</label>
<input type="radio" name="cheese" id="no" value="yes">
<label for="no">No</label>
</section>
<hr>
<section class="bun-type">
<label for="bun">What type of bun would you like?</label>
<select name="bun" id="bun">
<option value="sesame">Sesame</option>
<option value="potatoe">Potato</option>
<option value="pretzel">Pretzel</option>
</select>
</section>
<hr>
<section class="sauce-selection">
<label for="sauce">What type of sauce would you like?</label>
<input list="sauces" id="sauce" name="sauce">
<datalist id="sauces">
<option value="ketchup"></option>
<option value="mayo"></option>
<option value="mustard"></option>
</datalist>
</section>
<hr>
<section class="extra-info">
<label for="extra">Anything else you want to add?</label>
<br>
<textarea id="extra" name="extra" rows="3" cols="40"></textar
ea>
</section>
<hr>
<section class="submission">
<input type="submit" value="Submit">
</section>
</form>
</section>
</body>
</html>
Form validation:
The Validation is the concept of checking user provided data against the required data.
1. Server-side validation :happens when data is sent to another machine for validation.eg. Logine
page
2. Client side validation: if we want to check the data data on the browser(the client) this validation
occurs before data is sent to the server.
Easy to Understand: Semantic HTML also makes the website’s source code
easier to read for other web developers.