Published by: Sujan
Published date: 14 Jun 2021
HTML (Hypertext Markup Language) is the language used to create web documents. It defines the syntax and placement of special instructions (tags) that aren’t displayed but tell the browser how to display the document’s contents. It is also used to create links to other documents, either locally or over a network such as the Internet.
The HTML standard and all other Web-related standards are developed under the authority of the World Wide Web Consortium (W3C).
Basic Structure of HTML
The HTML file is always saved in .html format.
An HTML element is defined by a start tag, some content, and an end tag:
<tagname>Here you write the content.</tagname>
The HTML element is everything from the start tag to the end tag:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
Every HTML tag is made up of a tag name, sometimes followed by an optional list of attributes, all of which appear between angle brackets < >. Nothing within the brackets will be displayed in the browser. The tag name is generally an abbreviation of the tag’s function (this makes them fairly simple to learn). Attributes are properties that extend or refine the tag’s function.
The name and attributes within a tag are not case-sensitive. <BODY BGCOLOR=white> will work the same as <body bgcolor=white>. However, values for particular attributes may be case sensitive, particularly URLs and filenames.
There are two types of tags:
Most HTML tags are containers, meaning they have a beginning (also called “opener” or “start”) tag and an end tag. The text enclosed within the tags will follow the tag’s instructions, as in the following example:
The weather is <I>gorgeous</I> today. Result: The weather is gorgeous today.
An end tag contains the same name as the start tag, but it is preceded by a slash (/). You can think of it as an “off” switch for the tag. End tags never contain attributes. For some tags, the end tag is optional and the browser determines when the tag ends by context. This practice is most common with the <p> (paragraph) tag.
A few tags do not have end tags because they are used to place standalone elements on the page. The image tag (<img>) is such a tag and it simply plops a graphic into the flow of the page. Other standalone tags include the line break (<br>), horizontal rule (<hr>), and tags that provide information about a document and don’t affect its displayed content, such as the <meta> and base> tags.
Attributes are added within a tag to extend or modify the tag’s actions. You can add multiple attributes within a single tag. Tag attributes, if any, belong after the tag name, each separated by one or more spaces. Their order of appearance is not important.
href
attribute of <a>
specifies the URL of the page the link goes to.src
attribute of <img>
specifies the path to the image to be displayed.width
and height
attributes of <img>
provide size information for images.alt
attribute of <img>
provides an alternate text for an image.style
the attribute is used to add styles to an element, such as color, font, size, and more.lang
attribute of the <html>
tag declares the language of the Web page.title
an attribute defines some extra information about an element.The following are examples of tags that contain attributes:
<IMG SRC=”graphics/pixie.gif” ALIGN=right WIDTH=45 HEIGHT=60> <BODY BGCOLOR=”#000000″>
<FONT FACE=”Trebuchet MS, Arial, Helvetica” SIZE=4>