Web Unit 2
Web Unit 2
What is HTML?
Markup Language means Text between tags that define the structure.
HTML is a markup language that is used to create web pages. It defines how the
web page looks and how to display content with the help of elements.
It forms or defines the structure of our Web Page, thus it forms or defines the
structure of our Web Page. We must remember to save your file with .html
extension.
Applications of HTML
HTML is used for various purposes. Let us take a look at them
Clinet-side storage
Game development
HTML Editor
Simple editor: Notepad Visual Studio Code Notepad++
Atom
For instance, a home page, an about page, and a contact page would all have separate HTML
files. HTML documents are files that end with a .html or .htm extension.
A web browser reads the HTML file and renders its content so that internet users can view it.
All HTML pages have a series of HTML elements, consisting of a set of tags and attributes.
A tag tells the web browser where an element begins and ends, whereas an attribute describes
the characteristics of an element.
The three main parts of an element are:
Opening tag – used to state where an element starts to take effect. The tag is wrapped
with opening and closing angle brackets. For example, use the start tag <p> to create a
paragraph.
Closing tag – the same as the opening tag, but with a forward slash before the element
name. For example, </p> to end a paragraph.
The combination of these three parts will create an HTML element:
For example, a style element adding the color purple and the font-family verdana will look
like this:
HTML Skeleton
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
You can declare all the elements
</body>
</html>
HTML Basic
<!DOCTYPE html>
Instruction to the browser about the HTML version.
<html>
<head>
Everything written here will never be displayed in the browser. It contains general information about the
document Title, definitions of CSS and script sheets Metadata(information about the document)
<body>
Everything written here will be displayed in the browser .Contains text, images, links that can be achieved
through tags
Examples:
<p> This is our first paragraph. </p>
<a href=”http://www.google.com”>Go To Google</a>
<img src=”photo.jpg”>
HTML Comment
Single line
Multiple lines
Comment tag //Supported by IE
How Does HTML Work?
What are HTML tags?
Essentially, HTML tags are markers which tell the browser how the enclosed text
should be displayed. Here’s a simple example:
<b>This text should be bold.</b>
In this case, <b> and </b> are the HTML tags. They are marking the enclosed text as
“bold”—hence, the “markup” element of HTML. We’ll explain how to actually write tags
in the next section.
Once the document is complete, the author saves it as a html file and opens it in their
internet browser. The browser then reads the file and follows the instructions to render the
page in a certain way—as provided by the HTML tags.
So, when you use the “bold” tags, you’re essentially telling the browser to display this
sentence in bold:
When the browser reads this, it knows to display the sentence as described: This text should
be bold. Of course, the HTML tags themselves are not displayed in the browser (unless you
make a mistake writing them!).
Tags
HTML tags are written inside angle brackets, and tend to come in pairs—so, they consist of both an opening and a
closing tag.
For example, the <p> tag is used to indicate a new paragraph. The opening tag is written as follows:
<p>. After this tag, you write your paragraph. To finish, add your closing tag, which is the same as the opening tag
but with a forward slash. In this case, it would be: </p>.
A pair of tags with text enclosed is known as an element. Here are some examples of common HTML elements
and their corresponding tags:
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<b>This is a bold sentence</b>
<i>This is an italic sentence</i>
Most HTML tags follow this open-and-closing pattern, but there are also some tags which only need an opening
tag to be valid.
These are known as singleton tags, and include things like <br> to indicate a line break, and <img> for including
an image.
The browser will understand and act on these tags without the need for a closing tag.
Attributes
Attributes provide extra information about the text contained within the tags.
For example, if you wanted to hyperlink the phrase “my website” in your HTML document, you would
first use the tag pairs <a> and </a> to specify that the text should be linked.
To tell the browser where the text should be linked to—i.e. the link address—you use the href attribute.
Attributes, like the text, are always enclosed within the tags: