HTML Web Dev
HTML Web Dev
Contents
INTERNET AND WEB TECHNOLOGY .......................................................................... 1
2. HTML (Hypertext Markup Language): ....................................................................... 1
a. Designing Webpages Process ...................................................................................... 1
b. Structuring HTML and Basic Input Tags: ................................................................... 5
i) The DOCTYPE Identifier......................................................................................... 5
ii) The <html> Tag ....................................................................................................... 6
iii) The <head> Tag ..................................................................................................... 6
iv) The <title> Tag ....................................................................................................... 6
v) The <body> Tag ...................................................................................................... 7
c. Basic Tags .................................................................................................................... 7
i) Headings ................................................................................................................... 7
ii) Paragraphs ............................................................................................................... 7
iii) HTML Horizontal Rules ........................................................................................ 8
iv) HTML Line Breaks ................................................................................................ 8
v) Links ........................................................................................................................ 8
vi) Images ..................................................................................................................... 9
vii) Lists ..................................................................................................................... 15
viii) HTML Formatting Elements .............................................................................. 17
ix) Tables ................................................................................................................... 18
x) Forms ..................................................................................................................... 21
d. Webpage Structure ..................................................................................................... 25
e. HTML Block and Inline Elements ............................................................................. 32
f. Group Content with Divs and Spans .......................................................................... 33
g. Add Classes and Ids to elements ................................................................................ 36
h. HTML Comment Tags ............................................................................................... 38
INTERNET AND WEB PAGE AUTHORIZATION
HTML5 is the current active specification for HTML, or Hypertext Markup Language.
HTML forms the content layer of the web, providing a way to structure information in a way
that can be rendered by browsers and processed by search engine crawlers.
HTML5 was initially released in 2008, and has added additional features since then. It
improves on earlier versions by enabling native multimedia content, support for SVG and
MathML vector graphics, and new semantic document elements.
HTML is useful on its own, but much of its power is unlocked by the web’s other layers. CSS
is the styling layer that determines how this content is displayed. JavaScript is the behavior
layer that allows user interaction and dynamic data manipulation.
1. Goal identification
In this initial stage, the designer needs to identify the end goal of the website design, usually in
close collaboration with the client or other stakeholders. Questions to explore and answer in
this stage of the design and website development process include:
Who is the site for? What do they expect to find or do there? Is this website’s primary aim to
inform, to sell (ecommerce, anyone?), or to amuse? Does the website need to clearly convey a
brand’s core message, or is it part of a wider branding strategy with its own unique focus? What
competitor sites, if any, exist, and how should this site be inspired by/different than, those
competitors?
Tools for website goal identification stage
Audience personas, Creative brief, Competitor analyses, Brand attributes
2. Scope definition
One of the most common and difficult problems plaguing web design projects is scope creep.
The client sets out with one goal in mind, but this gradually expands, evolves, or changes
1
INTERNET AND WEB PAGE AUTHORIZATION
altogether during the design process — and the next thing you know, you’re not only designing
and building a website, but also a web app, emails, and push notifications.
If the increased expectations aren’t matched by an increase in budget or timeline, the project
can rapidly become utterly unrealistic.
The next step is to find some design inspiration and build the wireframe. Wireframes provide
a framework for storing the site’s visual design and content elements, and can help identify
potential challenges and gaps with the sitemap.
Tools for sitemapping and wireframing
Pen/pencil and paper, Balsamiq, Moqups, Sketch, Axure, Webflow
4. Content Creation
Content serves two essential purposes:
Purpose 1. Content drives engagement and action
2
INTERNET AND WEB PAGE AUTHORIZATION
First, content engages readers and drives them to take the actions necessary to fulfill a site’s
goals. This is affected by both the content itself (the writing), and how it’s presented (the
typography and structural elements).
Purpose 2: SEO
Content also boosts a site’s visibility for search engines. The practice of creation and improving
content to rank well in search is known as search engine optimization, or SEO.
Getting your keywords and key-phrases right is essential for the success of any website.
Awesome content creation tools
Google Docs, Dropbox Paper, Quip, Gather Content, Webflow CMS (content management
system)
5. Visual Elements
Finally, it’s time to create the visual style for the site. This part of the design process will often
be shaped by existing branding elements, color choices, and logos, as stipulated by the client.
Images are taking on a more significant role in web design now than ever before. Not only do
high-quality images give a website a professional look and feel, but they also communicate a
message, are mobile-friendly, and help build trust.
A mockup is the equivalent of a printed version of your website that allows customers to see
all the visual aspects of the proposed site, the overall layout, details such as colors, fonts, some
images, icons, logos, and the list goes on!
Imagine printing out a website before the website itself has even been built. Mockups are
created after a thorough study of a client's needs, a process which is often accompanied by
something called a spec sheet.
A spec sheet is a document that lists customer needs as well as the eventual process you will
adopt to end up with a final result. It is extremely important to have one to make sure that you
and your client are working towards the same goal.
Tools for visual elements
The usual suspects (Sketch, Illustrator, Photoshop, etc.), Moodboards, style tiles, element
collages, Visual style guides
3
INTERNET AND WEB PAGE AUTHORIZATION
The mockup and spec sheet combination is great because it allows the customer and developer
to be very much on the same page in terms of project and planning. For developers, this is
especially great, since many of the important website design and layout choices have already
been made!
Devise a simple, consistent naming system for your pages, images and other external files.
4
INTERNET AND WEB PAGE AUTHORIZATION
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
5
INTERNET AND WEB PAGE AUTHORIZATION
<body>
Page Content
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>This is the Title. It will be explained later on</title>
</head>
...your page...
</html>
6
INTERNET AND WEB PAGE AUTHORIZATION
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>This is the Title</title>
</head>
<body>
...your page...
</body>
</html>
c. Basic Tags
i) Headings
Headings are used to add titles to sections of a page. HTML defines six levels of headings.
They are defined with the <h1> to <h6> tags.
Heading tags look like the following:
<h1>Heading 1</h1>
<h2> Heading 2</h2>
<h3> Heading 3</h3>
<h4> Heading 4</h4>
<h5> Heading 5</h5>
<h6> Heading 6</h6>
ii) Paragraphs
A paragraph always starts on a new line, and is usually a block of text and browsers
automatically add some white space (a margin) before and after a paragraph. HTML paragraphs
are defined with the <p> tag. Paragraph tags are two-sided (<p>...</p>), <p>indicates the
7
INTERNET AND WEB PAGE AUTHORIZATION
beginning of the paragraph and </p> (the closing tag) indicates where one paragraph ends.
Example: <p>This is some text.</p>
v) Links
HTML links are hyperlinks. To create a link in an HTML page, you use the HTML link tag
<a>...</a>. The <a> tag often is called an anchor tag because it also can be used to create
anchors for links. It allows you can click on a link and jump to another document.
Note: A link does not have to be text. It can be an image or any other HTML element.
Syntax: <a href="url">link text</a>
Examples
Local Link:
Go back to <a href="[Link]">Main Menu</a> Links you to the same website.
External Link:
<a href="[Link] Google for more. </a> Links you to different website.
8
INTERNET AND WEB PAGE AUTHORIZATION
The target attribute specifies where to open the linked document. The target attribute can have
one of the following values:
_blank - Opens the linked document in a new window or tab
_self - Opens the linked document in the same window/tab as it was clicked (this is default)
_parent - Opens the linked document in the parent frame
_top - Opens the linked document in the full body of the window
framename - Opens the linked document in a named frame
vi) Images
A picture is worth a thousand words! That's why you'll likely include images in your web pages
at some point, whether it's to display a user's profile picture, show a vacation photo, add some
visual enhancement to an article, or something else!
In HTML, images are defined with the <img> tag. The <img> tag is empty, it contains
attributes only, and does not have a closing tag.
Syntax: <img src="url">
Example:
<img src="[Link]
[Link]" alt="Astronaut Millie Hughes-Fulford displays the modernist Blackburn &
Danne NASA logotype." title="Millie Hughes-Fulford"
Output:
9
INTERNET AND WEB PAGE AUTHORIZATION
Image Attributes
1. The src attribute
The first attribute to include in an <img> element is src. The contents of the src attribute
indicate where the image is stored. An image can be loaded from:
Pay attention to the If you loaded the image from Wikimedia directly, you could write the
following within your img tag:
src="[Link]
If you saved the image among your own files, you could write:
src="images/[Link]"
10
INTERNET AND WEB PAGE AUTHORIZATION
There's no http:// or https:// in the second example, meaning you're probably working with a
file in your own project; not one hosted elsewhere on the web.
Storing images in among your own files is a good habit to get into (but only if you have the
rights to the image! More on that in the next chapter). Even if Wikimedia were to remove the
image above from their site or change the link, you'd still have it in your own files and would
thus be spared the embarrassment of a broken image.
It is common to save images in a folder called images that lives within your website project.
We'll see this later in the course.
Once you have told the <img> tag where the image is located (via the src attribute), you must
add a description of the image within another attribute: alt.
Think of "alt" like "alternative text." The alt attribute provides an alternate text for an image,
if the user for some reason cannot view it (because of slow connection, an error in the src
attribute, or if someone is using a screen reader and can't see your image with their eyes, they
will see the descriptive text of the image instead). So will search engines, which is important
for SEO.
SEO stands for Search Engine Optimization, which is concerned with, among other things,
improving the quality and the quantity of user traffic to websites.
A good alt text to describe the Millie Hughes-Fulford photo would be: "Astronaut Millie
Hughes-Fulford displays the modernist Blackburn & Danne NASA logotype." It's sufficiently
descriptive so that even users who can't see your page won't miss any of the important
information contained in the photo!
However, if an image truly adds no additional information to the page and is purely
decorative, you can leave the quotation marks empty (like for a decorative dot image):
11
INTERNET AND WEB PAGE AUTHORIZATION
The title of your image appears when a user hovers over the image itself, as in the Millie
Hughes-Fulford image above. See how hovering with the cursor brings up the contents of the
title attribute?
Figures also allow for captions. Fun fun! To insert a figure, surround your <img> tag with
two other tags: <figure> and <figcaption>.
<figure>
<img src="[Link]
[Link]" alt="Astronaut Millie Hughes-Fulford displays the modernist Blackburn &
Danne NASA logotype." title="Millie Hughes-Fulford">
<figcaption>Millie Hughes-Fulford</figcaption>
12
INTERNET AND WEB PAGE AUTHORIZATION
</figure>
Result
Use the best images possible
Using <figure> is a great way to write semantically wonderful HTML. "Figure" is more
descriptive than "image", so if figure suits your content, it's a good choice to use it.
When adding images to your code, there are a few things to bear in mind, like intellectual
property and file formats/sizes that ensure the best browsing experience.
Finding images
As you continue building websites, you'll have opportunities to add many different kinds of
images. Some, you can make yourself. You can create charts to show relevant figures, use your
own photography for an article, mark up screenshots to illustrate a concept, or hand-draw
illustrations to accompany a story.
Some images, you just can't get yourself, though. This is not an excuse to use copyrighted
images without attribution or photographs that aren't yours.
13
INTERNET AND WEB PAGE AUTHORIZATION
Stock images are a safe choice when you're in a tight spot and need visuals to accompany your
text! Here are some solid options if you need stock photos:
Shutterstock: [Link]
iStock: [Link]
Fotolia: [Link]
Now that you have the resources where you can find the perfect image(s) for your needs, let's
do a brief rundown of image formats.
Image formats
It is good that images should often be saved in their own folder in their codebase. There are
several different image formats (otherwise known as file types) available, and you should be
sure to save or use image with the one most suited to your page's needs:
JPEG
Most digital cameras save photos in JPEG or JPG (they're the same thing) format because it
can blend red, green, and blue to produce many colors. JPEG is a good format to use when
adding a photo with many colors or with photography in general. After all, the JPEG stands for
Joint Photographic Experts Group. Sample image files could be winter_landscape.jpg or
family_portrait.jpeg .
GIF
Everyone loves animated GIFs. That's because this file type is perfect for animated images. It's
less suited to photography though because it can't handle as many colors. You can still use it
for still photos with very few colors, like simple logos. It also allows for transparency, which
JPEGs do not. A sample image file could be brand_logo.gif or dancing_bear.gif .
PNG
14
INTERNET AND WEB PAGE AUTHORIZATION
There are two different types of PNG formats, PNG-8 and PNG-24. The latter allows for more
colors, but both formats allow transparency and do not result in quality loss when saved over
and over again (unlike JPEGs). PNG stands for Portable Network Graphics. A sample image
file could be simple_illustration.png or transparent_background_cutout.png.
SVG
If the name "Scalable Vector Graphics" doesn't give it away, SVG images are vector images.
They can be scaled up or down and not lose any quality. However, they're only suited to simple
images like logos or flags. Sample image files could be [Link] or american_flag.svg .
One of the most important things you can do when building great web pages is to keep your
image sizes reasonable and to measure your images in pixels. If you want to show an image at
a size of 200px by 200px, it should be saved at that size. This will help your pages load faster!
vii) Lists
HTML lists allow web authors to group a set of related items in lists. HTML defines
these three types of lists:
• Numbered or ordered lists, which are typically labeled with numbers
• Bulleted or unordered lists, which are typically labeled with bullets or some other
symbol
• Description lists, in which each item in the list has a term and a definition for that term,
arranged so that the term is somehow highlighted or drawn out from the text
List Tags
All the list tags have the following common elements:
• The entire list is surrounded by the appropriate opening and closing tag for the type of list
(for example, <ul> and </ul> for unordered lists, or <ol> and </ol> for ordered lists).
• Each list item within the list has its own tag:
<dt> and <dd> for the glossary lists, and <li> for all the other lists.
Ordered Lists
The HTML <ol> tag defines an ordered list. An ordered list can be numerical or alphabetical.
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
Input
<p>Installing Your New Operating System</p>
<ol>
15
INTERNET AND WEB PAGE AUTHORIZATION
Input
<p>The Last Six Months of the Year (and the Beginning of the NextYear):</p>
<ol type="I" start="7">
<li>July</li>
<li>August</li>
<li>September</li>
<li>October</li>
<li>November</li>
<li>December</li>
<li type="1">January</li>
</ol>
ix) Tables
Table Parts
Before getting into the actual HTML code to create a table, let's look at the following terms so
that we both know what we're talking about:
• The caption indicates what the table is about: for example, "Voting Statistics" or "Toy
Distribution Per Room" Captions are optional.
• The table headings label the rows, columns, or both. Usually they're in an emphasized font
that's different from the rest of the table. They're optional.
18
INTERNET AND WEB PAGE AUTHORIZATION
• Table cells are the individual squares in the table. A cell can contain normal table data or a
table heading.
• Table data is the values in the table itself. The combination of the table headings and table
data makes up the sum of the table.
The <table> Element
The to create a table in HTML, you use <table>...</table> element to enclose the code for an
optional caption, and then add the contents of the table itself:
<table>
...table caption (optional) and contents...
</table>
Rows and Cells
The cells within each row are created using one of two elements:
• <th>...</th> elements are used for heading cells. Generally, browsers center the contents
of a <th> cell and render any text in the cell in boldface.
• Each table row is defined with the <tr> tag
• <td>...</td> elements are used for data cells. TD stands for table data.
Input
<table>
<tr>
<th>Name</th>
<td>Alison</td>
<td>Tom</td>
<td>Susan</td>
</tr>
<tr>
<th>Height</th>
<td>5'4"</td>
<td>6'0"</td>
<td>5'1"</td>
</tr>
<tr>
<th>Weight</th>
<td>140</td>
<td>165</td>
19
INTERNET AND WEB PAGE AUTHORIZATION
<td>97</td>
</tr>
</table>
Setting Table Widths
To make a table as wide as the browser window, you add the width attribute to the table, as
shown in the following line of code:
<table border="1" width="100%">
Changing Table Borders
You can change the width of the border drawn around the table. If border has a numeric value,
the border around the outside of the table is drawn with that pixel width. The default is
border="1". border="0" suppresses the border, just as if you had omitted the border attribute
altogether.
Input
<table border="10" width="100%">
Cell Padding
The cell padding attribute defines the amount of space between the edges of the cells and the
content inside a cell.
Input
<table cellpadding="10" border="1">
Cell Spacing
Cell spacing is similar to cell padding except that it affects the amount of space between
cells that is, the width of the space between the inner and outer lines that make up the
table border.
Input
<table cellpadding="10" border="4" cellspacing="8">
Spanning Multiple Rows or Columns
The tables you've created up to this point all had one value per cell or the occasional empty
cell. You also can create cells that span multiple rows or columns within the table.
Those spanned cells then can hold headings that have subheadings in the next row or column
or you can create other special effects within the table layout.
Input
<!DOCTYPE html>
<html>
<head>
20
INTERNET AND WEB PAGE AUTHORIZATION
x) Forms
HTML Forms are required, when you want to collect some data from the site visitor. For
example, during user registration you would like to collect information such as name, email
address, credit card, etc.
A form will take input from the site visitor and then will post it to a back-end application such
as CGI, ASP Script or PHP script etc. The back-end application will perform required
processing on the passed data based on defined business logic inside the application.
There are various form elements available like text fields, textarea fields, drop-down menus,
radio buttons, checkboxes, submit buttons and more. To accept input from a user, you must
wrap all of your input fields inside a <form> tag.
The purpose of the <form> tag is to indicate where and how the user's input should be sent.
First, let's look at how the <form> tag affects page layout. Forms are block-level elements.
21
INTERNET AND WEB PAGE AUTHORIZATION
The <input> element is the most important form element. The <input> element is displayed in
several ways, depending on the type attribute.
Examples:
<input type="text"> Defines a single-line text input field
<input type="radio"> Defines a radio button (for selecting one of many choices)
<input type="submit"> Defines a submit button (for submitting the form)
Form Attributes
The two most commonly used attributes of the <form> tag are action and method. Both of these
attributes are optional. The following example shows how the <form> tag is typically used:
<form action="someaction" method="get or post">
content, form controls, and other HTML elements
</form>
Action specifies the URL to which the form is submitted. Again, remember that for the form
to be submitted successfully, the script must be in the exact location you specify and must work
properly.
The method attribute supports two values: get or post. The method indicates how the form data
should be packaged in the request that's sent back to the server.
The GET method appends the form data to the URL in the request. Always use POST if the
form data contains sensitive or personal information. The POST method does not display the
form data in the page address field.
Other form attribute
Target
Specify the target window or frame where the result of the script will be displayed. It takes
values like _blank, _self, _parent etc.
Enctype
You can use the enctype attribute to specify how the browser encodes the data before it sends
it to the server. Possible values are −
application/x-www-form-urlencoded − This is the standard method most forms use in simple
scenarios.
mutlipart/form-data − This is used when you want to upload binary data in the form of files
like image, word file etc.
22
INTERNET AND WEB PAGE AUTHORIZATION
of select lists is to display a pull-down list that enables the user to select one of the options.
Here's an example of how one is created:
Input
<p>Please pick a travel destination:
<select name="location">
<option>Dar es Salaam</option>
<option>Mbeya</option>
<option>Iringa</option >
<option>Arusha</option>
</select>
</p>
d. Webpage Structure
When you build a house, you start by building a structure first, and then filling in the smaller
elements, right? The same is true when building a web page!
What do the New York Times, Wikipedia, and Airbnb website have in common? They can all
be broken down into predictable blocks. You could actually name almost any website, and you
could break down the site into remarkably predictable sections. Developers write HTML in a
way that permits consistent content structure across the entire web. This reduces cognitive
work for users and makes different sites display reliably across browsers, screen readers, and
search engines.
Check out the following examples and note their different sections:
25
INTERNET AND WEB PAGE AUTHORIZATION
26
INTERNET AND WEB PAGE AUTHORIZATION
Three different sites, but they all use the same structural elements, or zones: headers, navigation
areas, sections, and articles.
For example, if you look at the New York Times, they use the nav for browsing sections,
searching for an article, or accessing membership options and account settings. On Airbnb, the
nav allows you become a host or access your account settings. The navigation bars are suited
to each site's content but are not fundamentally different.
Additionally, websites often rearrange their content blocks when viewed on mobile devices
and tablets. You'll often notice articles or smaller content pieces stacking vertically on smaller
screen sizes.
<header>: the section at the top of a web page that often includes a logo and sometimes a nav
<nav>: a set of menu items that allow a user to navigate to different pages on a site
<section>: a general section of related content
<article>: a piece of content that can be independently shared, like a blog post or newspaper
article (even if you don't display the full article text, like you just show a preview, you can still
use an article tag to delineate this content)
27
INTERNET AND WEB PAGE AUTHORIZATION
<footer>: the section at the bottom of a page that often has additional links and perhaps social
sharing icons
<aside>: content that is complementary but not crucial to the page's main content (this could
be an informative side section on a related subject)
<figure>: a grouped image and caption that create an informative visual of some kind
Let's look at a very generic desktop page structure first:
The page is pretty wide. Now let's look at a real-life example. You can see that on the website
Etsy, content does indeed have a layout that spreads out from left to right:
28
INTERNET AND WEB PAGE AUTHORIZATION
On the other hand, mobile views often "stack" elements vertically so they take up less
horizontal space.
29
INTERNET AND WEB PAGE AUTHORIZATION
30
INTERNET AND WEB PAGE AUTHORIZATION
<h1>Camping essentials</h1>
The format is exactly the same for creating structural elements like sections or footers. The
following tags create the structural elements in the website examples above:
31
INTERNET AND WEB PAGE AUTHORIZATION
<header>
<!--content-->
</header>
<nav>
<!--content-->
</nav>
<section>
<!--content-->
</section>
<article>
<!--content-->
</article>
<footer>
<!--content-->
</footer>
32
INTERNET AND WEB PAGE AUTHORIZATION
Headings
Paragraphs (p)
Lists and list items (ul, ol, li)
Structuring elements (header, nav, section, article, aside, figure, footer)
Inline elements that you've seen so far include:
Images (img)
Emphasized text (em)
Strong text (strong)
Links (a)
33
INTERNET AND WEB PAGE AUTHORIZATION
Most of the time, when you want to group content together, you'll be able to do it using an
HTML5 semantic element like header, nav, section, article, footer, figure, or aside. However,
sometimes your content doesn't really fit any of these categories! In that case, you're
encouraged to use divs to create block-level content groups.
One heading and four paragraphs, two of which have a dark green background and small text
The dark green disclaimer block isn't really a full section, nor is it an article, footer, nav, etc.
Nonetheless, its two paragraphs need to be grouped together so the block's appearance can be
changed to have a dark green background and be visually different using CSS (you'll see this
later in the course).
This is a legitimate reason to use a div to group the two paragraphs together.
34
INTERNET AND WEB PAGE AUTHORIZATION
<article>
<div>
<p>Note: this is an editorial piece and does not reflect the official opinion of
the Sun Journal.</p>
<p>For more information about our editorial team, click <a href="#">here</a>.</p>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Id cursus metus aliquam eleifend mi in
nulla. Lorem mollis aliquam ut porttitor leo a. Nisl vel pretium lectus quam id leo in
vitae. Bibendum neque egestas congue quisque egestas diam.</p>
<p>Diam in arcu cursus euismod quis. Aliquet lectus proin nibh nisl. Blandit massa
enim nec dui nunc mattis enim ut tellus. Integer enim neque volutpat ac tincidunt vitae.
Amet porttitor eget dolor morbi non arcu risus. Orci phasellus egestas tellus rutrum
tellus pellentesque eu tincidunt tortor.</p>
</article>
Do you see where we isolated the section we wanted using a <div>?
Spans
Spans are similar to divs, except they are inline elements. You might use them to group words
together, since words appear inline and not each on their own line.
Imagine the newspaper above always prints its name in bolded light green. You need to grab
those two words — "Sun Journal" — to be able to apply CSS to them. Why not wrap them in
a <span>?
<p>Note: this is an editorial piece and does not reflect the official opinion of the
<span>Sun Journal.</span></p>
Result
35
INTERNET AND WEB PAGE AUTHORIZATION
Let's say you're working on a news website, which is likely to contain paragraphs and
paragraphs of text. Some paragraphs will be within news articles, others might be disclaimer
text at the bottom of the page, others will be short article blurbs; in sum, you have no way to
tell these paragraphs apart from one another. Since they're all just <p> tags, you won't be able
to apply CSS (appearance) changes to some paragraphs but not others.
Classes and ids are custom attributes you can add to your elements in order to distinguish them
from one another.
Classes apply to groups of elements, and ids apply to only one single element on an entire
page. Let's check out classes first.
These examples will include basic CSS to help you visualize how ids and classes are used, but
you're not expected to know CSS yet! Don't stress about it.
Classes
Setting a class attribute is as simple as choosing the class name and adding the attribute to your
element, like:
36
INTERNET AND WEB PAGE AUTHORIZATION
Classes like this allow you to apply custom CSS to certain elements but not others. Take this
web page screenshot with filler text:
Two "warning" style paragraphs have a different background color than the others
The code behind it has 6 different paragraph tags, but 2 of them are orange to indicate a
warning, or something the reader should watch out for. The way to accomplish this is to add a
class of "warning" to the appropriate paragraphs:
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur arcu massa,
placerat et laoreet et, blandit ut tellus.</p>
<p>Pellentesque ac enim vel neque volutpat luctus vitae quis lorem. Mauris sit amet mi
vehicula, pharetra odio eu, aliquet ipsum. Nullam luctus sem quis quam suscipit
condimentum. Vestibulum orci mi, tincidunt vitae eleifend in, fringilla ac tellus. Fusce
imperdiet ante erat, volutpat fringilla est commodo nec. </p>
<p class="warning">Watch out! Nunc vulputate sit amet enim ut efficitur. Sed volutpat
nunc in viverra pretium.</p>
<p>Maecenas quis nunc facilisis, cursus diam eget, bibendum lectus. Aenean iaculis nunc
in mollis vehicula. Vivamus urna turpis, fringilla eu efficitur ac, luctus sed magna.</p>
<p>Integer vel quam consequat, accumsan nisi nec, consequat dolor. Vestibulum ante ipsum
primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis ultrices nisi vel
elementum luctus.</p>
<p class="warning">Watch out! Mauris et quam nec felis mattis sagittis vel eget felis.
Proin tempor nibh in sollicitudin aliquam. Donec scelerisque non arcu id molestie. Nullam
luctus aliquam augue, non rhoncus dui auctor in.</p>
By adding class="warning" as an attribute to certain paragraph tags, you can grab the
relevant paragraphs and update the background color to orange for specific paragraphs!
37
INTERNET AND WEB PAGE AUTHORIZATION
ids
Ids are just like classes — they are custom attributes that can be added to elements —
except they'll only apply to one element per page.
There were multiple warning paragraphs. On the same page, let's say we want to have one
single key takeaway (added to the HTML above):
<p id="key-takeaway">Therefore, this is the one thing you should remember from the whole
page.</p>
There will only be one key takeaway per page, so we're safe to use an id on this element instead
of a class!
Now in CSS, you can adapt that one element's appearance!
You can add comments to your HTML source by using the following syntax:
<!-- Write your comments here -->
Notice that there is an exclamation point (!) in the start tag, but not in the end tag. Comments
are not displayed by the browser, but they can help document your HTML source code. With
comments you can place notifications and reminders in your HTML code:
Example
<!-- My comment goes here-->
<p>This is a paragraph.</p>
QUESTIONS:
1. What are the different lists available explain briefly.
2. Explain the different tags and attributes available in table briefly.
3. What are the different tags available to create the elements of a form explain in detail.
38