HTML (HyperText Markup Language) is the most basic building block of the Web. It defines the
meaning
and structure of web content HTML uses "markup" to annotate text, images, and other content for
display in a Web browser. HTML stands for Hyper Text Markup
Language. HTML is the standard markup language for creating Web pages. HTML describes the
structure
of a Web page. HTML consists of a series of elements. HTML elements tell the browser how to
display
the content. HTML elements label
pieces of content such as "this is a heading", "this is a paragraph", "this is a link", etc.
Structure of HTML Document
- The
<!DOCTYPE HTML> declaration defines that this document is an HTML5
document
- The
<HTML> element is the root element of an HTML page
- The
<head> element contains meta information about the HTML page
- The
<title> 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
An HTML element is an individual component of an HTML document. It represents semantics, or
meaning.
For example, the title element represents the title of the document. Most HTML elements are
written
with a start tag (or opening tag) and an end tag (or
closing tag), with content in between. Elements can also contain attributes that defines its
additional properties
HTML Tags vs. Elements
Technically, an HTML element is the collection of start tag, its attributes, an end tag and
everything
in between. On the other hand an HTML tag (either opening or closing) is used to mark the start or
end
of an element, as you can see in the above illustration.
However, in common usage the terms HTML element and HTML tag are interchangeable i.e. a tag is an
element is a tag. For simplicity's sake of this website, the terms "tag" and "element" are used to
mean
the same thing — as it will define
something on your web page
HTML Elements Types
Technically, an HTML element is the collection of start tag, its attributes, an end tag and
everything
in between. On the other hand an HTML tag (either opening or closing) is used to mark the start or
end
of an element, as you can see in the above illustration.
However, in common usage the terms HTML element and HTML tag are interchangeable i.e. a tag is an
element is a tag. For simplicity's sake of this website, the terms "tag" and "element" are used to
mean
the same thing — as it will define
something on your web page
The HTML id attribute is used to specify a unique id for an HTML element. You cannot have more
than
one element with the same id in an HTML document.
The id attribute specifies a unique id for an HTML element. The value of the id attribute must
be
unique within the HTML document. The id attribute is used to point to a specific style
declaration
in a style sheet. It is also used by JavaScript to access
and manipulate the element with the specific id. The syntax for id is: write a hash character
(#),
followed by an id name. Then, define the CSS properties within curly braces {}. In the following
example we have an
<h1> element that points to the id name "myHeader". This
<h1> element will be styled according to the #myHeader style definition in
the
head section:
<!DOCTYPE html>
<html>
<html>
<head>
</head>
<body>
<h1 id="myHeader">My Header</h1>
</body>
<html>
Difference Between Class and ID
The id attribute specifies a unique id for an HTML element. The value of the id attribute must be
unique
within the HTML document. The id attribute is used to point to a specific style declaration in a
style
sheet. It is also used by JavaScript to access
and manipulate the element with the specific id.
The syntax for id is: write a hash character (#), followed by an id name. Then, define the CSS
properties within curly braces {}. In the following example we have an element that points to
the id
name "myHeader". This element will be styled according
to the #myHeader style definition in the head section:
<!DOCTYPE html>
<html>
<head>
<h2 class="city"Paris</h2>
Multiple elements with same class
<h2 class="city"London</h2>
<p> London is the capital of England. </p>>
Responsive web design is about creating web pages that look good on all devices! A responsive
web
design will automatically adjust for different screen sizes and viewports. Responsive Web Design
is
about using HTML and CSS to automatically resize, hide,
shrink, or enlarge, a website, to make it look good on all devices (desktops, tablets, and
phones):
Setting The Viewport
To create a responsive website, add the following
<meta> tag to all your web pages:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Responsive images are images that scale nicely to fit any browser size. Using the width Property
If
the CSS width property is set to 100%, the image will be responsive and scale up and down:
<img src="img_girl.jpg" style="max-width:100%;height:auto;">
The text size can be set with a "vw" unit, which means the "viewport width"
<h1 style="font-size:10vw">Hello World</h1>
Semantic elements=elements with a meaning.>
Html <section> Element
Examples of where a Html <section> element can be used:
- Chapters
- Introduction
- News Items
- Contact Information
Html <article> Element
The
<article> element specifies independent, self-contained content. An article
should
make sense on its own, and it should be possible to distribute it independently from the rest of the
web
site. Examples of where
the
<article> element can be used:
- Forum Posts
- Blog Posts
- User Comments
- Product Cards
- Newspaper articles