Docsity

HTML Tags and attributes, Study notes of Web Application Development

Toggle sidebar
bg1
WEB DESIGNING UNIT II
CASC II BCOM
2
<head>
<title>My First Webpage</title>
</head>
<body>
<h1>Welcome to My Webpage</h1>
<p>This is my first paragraph of text!</p>
</body>
</html>
Output:
HTML
HTML Page Structure
The basic structure of an HTML page is shown below. It contains the essential building-block
elements (i.e. doctype declaration, HTML, head, title, and body elements) upon which all web
pages are created.
<!DOCTYPE html> - This is the document type declaration, not a tag. It declares
that the document is an HTML5 document.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d

Partial preview of the text

Download HTML Tags and attributes and more Study notes Web Application Development in PDF only on Docsity!

My First Webpage

Welcome to My Webpage

This is my first paragraph of text!

Output:

HTML

HTML Page Structure The basic structure of an HTML page is shown below. It contains the essential building-block elements (i.e. doctype declaration, HTML, head, title, and body elements) upon which all web pages are created.

 **** - This is the document type declaration, not a tag. It declares that the document is an HTML5 document.

 **** - This is called the HTML root element. All other elements are contained within it.  **** - The head tag contains the "behind the scenes" elements for a webpage. Elements within the head aren't visible on the front end of a webpage. Typical elements inside the include: o : Defines the title displayed on the browser tab. o <meta> : Provides information like the character set or viewport settings. o <link> : Links external stylesheets or resources. o <style> : Embeds internal CSS styles. o <script> : Embeds JavaScript for functionality.  <title> - The title is what is displayed on the top of your browser when you visit a website and contains the title of the webpage that you are viewing.

<h2> - The <h2> tag is a second-level heading tag.

<p> - The <p> tag represents a paragraph of text.  <body> - The body tag is used to enclose all the visible content of a webpage. In other words, the body content is what the browser will show on the front end. An HTML document can be created using an HTML text editor. Save the text file using the " .html" or " .htm" extension. Once saved as an HTML document, the file can be opened as a webpage in the browser. Note: Basic/built-in text editors are Notepad (Windows) and TextEdit (MacOS). Other advanced text editors include Sublime Text, Visual Studio Code , etc.

HTML Elements and HTML Tag HTML Elements and HTML Tags are related but distinct. An HTML element is the complete structure, including the opening tag, content (if any), and the closing tag (if applicable). On the other hand, A tag is the actual keyword or name enclosed in angle brackets (< >) that tells the browser what kind of content to expect.

Tag Description

Defines a list item

Defines a table

Defines an HTML form

To learn more about it follow the article - HTML Tags

HTML Attributes Attributes provide additional information about an element. They are placed inside the opening tag and are written as name="value". Common attributes include class, id, href, and src.

Example:

Visit Example  href is an attribute of the tag that defines the URL of the link. To learn more about it follow the article - HTML Attributes

Web Browser Unlike other programming languages, HTML does not show output on the any compiler. Web browsers is an compiler which show the results of an your HTML code. It reads HTML files and determines how to show content with the help of HTML tags. Any web browser ( Google, Safari, Mozilla Firefox , etc) can be used to open

a. HTML file and view the results.

index.html

Why Learn HTML?

Here are 5 common reasons to learn HTML :

1. Build Websites : HTML is the basic building block for creating any website. Learning

HTML can help you pursue a career in web development.

2. Customize Content : Allows you to edit or tweak web pages, emails, or templates

to fit your needs.

3. Understand how the web works : This helps you grasp how the internet works and

how web pages are structured.

4. Employment Opportunities : According to the Bureau of Labor Statistics, projects that

employment for web developers will grow 16% between 2022 and 2032, which is much faster than the average across all occupations.

5. Learn Easily : HTML is beginner-friendly, making it a great first step into the world of

coding and technology. Applications of HTMLWeb Development: HTML is the backbone of every webpage. It structures the content and integrates multimedia, hyperlinks, and more.  Web Applications: HTML, in combination with CSS and JavaScript, powers complex web applications (e.g., Google Docs, Trello).

Last Updated : 17 Jul, 2025

HTML ( HyperText Markup Language) is the standard markup language used to create and structure web pages.  It defines the layout of a webpage using elements and tags, allowing for the display of text, images, links, and multimedia content.  As the foundation of nearly all websites, HTML is used in over 95% of all web pages today, making it an essential part of modern web development.

In this guide, we learn the basics of HTML, which includes HTML tags ( ,

, , etc), attributes, elements, and document structure which collectively form a working web page.

HTML Basic Document and Structure Every HTML document begins with a document type declaration, setting the foundation for the webpage. This section introduces basic HTML tags that structure the page, such as , , and . Although this is not mandatory, it is a good convention to start the document with the below-mentioned tag.

HTML Structure

Below mentioned are the basic HTML tags that divide the whole page into various parts like head, body, etc.

Basic HTML Tags for Document Structure

Tags Descriptions

GeeksforGeeks is a online study platform

Code Overview:  This HTML document defines a basic webpage with a responsive design using tags, ensuring it adjusts well to different devices.  The content includes a paragraph

displaying "GeeksforGeeks is an online study platform," and the title "HTML" appears in the browser tab.

HTML Headings The HTML heading tags are used to create headings for the content of a webpage. These tags are typically placed inside the body tag. HTML offers six heading tags, from

to , each displaying the heading in a different font size. Syntax:

HTML

Heading 1 (h1) Heading 2 (h2) Heading 3 (h3) Heading 4 (h4) Heading 5 (h5) Heading 6 (h6)

// for Paragraph

Content...

// for Break

Code Overview:  This code displays six headings ( to ) on the webpage, with being the largest and most prominent and being the smallest.  The headings are used to define text hierarchy and emphasize content based on importance.

HTML Paragraph and Break Elements HTML

tags are used to write paragraph statements on a webpage. They start with the

tag and end with

. The HTML tag is used to insert a single line break and does not require a closing tag. In HTML, the break tag is written as . Syntax:

HTML

HTML stands for HyperText Markup Language. It is used to design web pages using a markup language.HTML is a combination of Hypertext and Markup language.Hypertext defines the link between web pages.A markup language is used to define the text document within the tag which defines the structure of web pages.

This is a multi-line comment

spanning multiple lines

A Computer Science portal for geeks A Computer Science portal for geeks A Computer Science portal for geeks

Code Overview :  to tags are used to define headings, with being the largest and the smallest.  Each tag displays "Hello World!" in decreasing font sizes, illustrating the hierarchy of headings in HTML.

HTML Comments HTML comments are annotations in your code that are not displayed in the browser. They are enclosed within tags and are primarily used for documentation, explanation, or temporarily disabling code during debugging. Syntax of HTML Comments

Single-line comment : __  Multi-line comment :

Example Usage of HTML Comments

HTML

Welcome to GeeksforGeeks

Learn HTML, CSS, and JavaScript here.

In this example, the comments provide context about the purpose of each HTML element. Best Practices for Using HTML CommentsBe concise and relevant : Write comments that explain the "why" behind the code in a brief and clear manner.  Avoid over-commenting : Do not state the obvious. Let the code itself explain when possible.  Keep comments up-to-date : Ensure comments reflect changes in the code to avoid confusion.

HTML Images The tag is used to insert an image into a webpage. The source of the image is specified within the src attribute, like this: . Syntax:

This HTML code uses the tag to display an image on a webpage.  The src attribute specifies the URL of the image, which is loaded and displayed when the page is rendered in the browser.

View HTML Source Code While checking a web page, you might want to see the HTML code behind it. Here we will see how you can view HTML source code for the entire page or a specific element.

1. View HTML Source Code of Entire Page

 To view the source code of a webpage press ctrl + u on the page, or right- click on the page and select the "view page source" option.  This will open a new tab that shows the HTML source code for that entire page.

2. Inspect an HTML Element on a Page

 To check the HTML code for a specific element on a page, right-click on the page and select the "Inspect" option.  This lets you see the HTML and CSS behind that element. You can also try making changes and see the changes.

 The element specifies a title for the HTML page (which is shown in the browser's title bar or in the page's tab)  The <body> element defines the document's body, and is a container for all the visible contents, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.  The <h1> element defines a large heading  The <p> element defines a paragraph

What is an HTML Element?

An HTML element is defined by a start tag, some content, and an end tag:

<tagname> Content goes here... </tagname>

The HTML element is everything from the start tag to the end tag:

<h1>My First Heading</h1>

<p>My first paragraph.</p>

Start tag Element content End tag

<h1> My First Heading </h1>

<p> My first paragraph. </p>

<br> none none

Note: Some HTML elements have no content (like the <br> element). These elements are called empty elements. Empty elements do not have an end tag!

ADVERTISEMENT

Web Browsers

The purpose of a web browser (Chrome, Edge, Firefox, Safari) is to read HTML documents and display them correctly.

A browser does not display the HTML tags, but uses them to determine how to display the document:

HTML Page Structure

Below is a visualization of an HTML page structure:

1993 Dave Raggett drafted HTML+

1995 HTML Working Group defined HTML 2.

1997 W3C Recommendation: HTML 3.

1999 W3C Recommendation: HTML 4.

2000 W3C Recommendation: XHTML 1.

2008 WHATWG HTML5 First Public Draft

2012 WHATWG HTML5 Living Standard

2014 W3C Recommendation: HTML

2016 W3C Candidate Recommendation: HTML 5.

2017 W3C Recommendation: HTML5.1 2nd Edition

2017 W3C Recommendation: HTML5.

HTML Global Attributes

HTML Global Attributes

The global attributes are attributes that can be used with all HTML elements.

Attribute Description

accesskey Specifies a shortcut key to activate/focus an element

class Specifies one or more classnames for an element (refers to a cla ss in

contenteditable Specifies whether the content of an element is editable or not

data-* Used to store custom data private to the page or application