HTML Basic in Single Word File
HTML Basic in Single Word File
</body>
</html>
Example Explained
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
HTML Documents
All HTML documents must start with a document type declaration: <!
DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
The <!DOCTYPE> Declaration
The <!DOCTYPE> declaration represents the document type, and helps
browsers to display web pages correctly.
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important
heading:
Example
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
Complete program
<!DOCTYPE html>
<html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
HTML Paragraphs
HTML paragraphs are defined with the <p> tag:
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
Complete program
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
HTML Links
HTML links are defined with the <a> tag:
Example
<a href=" www.mohitkadwal/">This is a Mohit Kadwal Information
Link</a>
Complete program
<!DOCTYPE html>
<html>
<body>
<h2>HTML Links</h2>
</body>
</html>
<html>
<body>
<p>HTML links are defined with the a tag. The link address is specified in the href attribute:</p>
</body>
</html>
HTML Images
HTML images are defined with the <img> tag.
The source file (src), alternative text (alt), width, and height are provided
as attributes:
Example
<img src="img_source.jpg " width="104" height="142">
Complete program
<!DOCTYPE html>
<html>
<body>
<h2>HTML Images</h2>
</body>
</html>
HTML Attributes
All HTML elements can have attributes
Attributes provide additional information about elements
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name="value"
Example
<img src="img_girl.jpg">
Complete program
<!DOCTYPE html>
<html>
<body>
<p>HTML images are defined with the img tag, and the filename of the image source is specified in
the src attribute:</p>
</body>
</html>
Example
<img src="img_girl.jpg" width="500" height="600">
Complete program
<!DOCTYPE html>
<html>
<body>
<p>The width and height attributes of the img tag, defines the width and height of the image:</p>
</html>
Example
<img src="img_girl.jpg" alt="Girl with a jacket">
Complete program
<!DOCTYPE html>
<html>
<body>
<p>The alt attribute should reflect the image content, so users who cannot see the image get an
understanding of what the image contains:</p>
</body>
</html>
Example
<p style="color:red;">This is a red paragraph.</p>
Complete program
<!DOCTYPE html>
<html>
<body>
</body>
</html>
HTML Styles
The HTML style attribute is used to add styles to an element, such as
color, font, size, and more.
Example
I am Red
I am Blue
I am Big
Complete program
<!DOCTYPE html>
<html>
<body>
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>
</body>
</html>
Background Color
The CSS background-color property defines the background color for an
HTML element.
Example
Set the background color for a page to powderblue:
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
Complete program
<!DOCTYPE html>
<html>
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Text Color
The CSS color property defines the text color for an HTML element:
Example
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
Fonts
The CSS font-family property defines the font to be used for an HTML
element:
Example
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
Text Size
The CSS font-size property defines the text size for an HTML element:
Example
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
Text Alignment
The CSS text-align property defines the horizontal text alignment for an
HTML element:
Example
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
The value of the title attribute will be displayed as a tooltip when you mouse
over the element:
Example
<p title="I'm a tooltip">This is a paragraph.</p>
Complete program
<!DOCTYPE html>
<html>
<body>
<p title="I'm a tooltip">Mouse over this paragraph, to display the title attribute as a tooltip.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<style>
table, th, td {
border:1px solid black;
</style>
<body>
<table style="width:100%">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
</body>
</html>
Table Cells
Each table cell is defined by a <td> and a </td> tag.
Everything between <td> and </td> are the content of the table cell.
Table Rows
Each table row starts with a <tr> and ends with a </tr> tag.
Table Headers
Sometimes you want your cells to be table header cells. In those cases use
the <th> tag instead of the <td> tag:
RowSpan:-
<table>
<tr>
<th>Name</th>
<th>Subject</th>
<th>Marks</th>
</tr>
<tr>
<td rowspan="3">Mark Smith</td>
<td>English</td>
<td>67</td>
</tr>
<tr>
<td>Maths</td>
<td>82</td>
</tr>
<tr>
<td>Science</td>
<td>91</td>
</tr>
</table>
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
Example
An unordered HTML list:
Item
Item
Item
Item
1. First item
2. Second item
3. Third item
4. Fourth item
<!DOCTYPE html>
<html>
<body>
<h2>An Unordered HTML List</h2>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<h2>An Ordered HTML List</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
The list items will be marked with bullets (small black circles) by default:
<!DOCTYPE html>
<html>
<body>
<h2>An unordered HTML list</h2>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>An ordered HTML list</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
The <dl> tag defines the description list, the <dt> tag defines the term
(name), and the <dd> tag describes each term:
<!DOCTYPE html>
<html>
<body>
<h2>A Description List</h2>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
</html>
Complete Program
<!DOCTYPE html>
<html>
<style>
div {
background-color: #FFF4A3;
}
</style>
<body>
<h1>HTML DIV Example</h1>
Lorem Ipsum <div>I am a div</div> dolor sit amet.
<p>The yellow background is added to demonstrate the footprint of the
DIV element.</p>
</body>
</html>
The <div> element has no required attributes, but style, class and id are
common.
<div> as a container
The <div> element is often used to group sections of a web page together.
Example
A <div> element with HTML elements:
<div>
<h2>London</h2>
<p>London is the capital city of England.</p>
<p>London has over 13 million inhabitants.</p>
</div>
Complete Program
<!DOCTYPE html>
<html>
<style>
div {
background-color: #FFF4A3;
}
</style>
<body>
<h1>HTML DIV Example</h1>
<div>
<h2>London</h2>
<p>London is the capital city of England.</p>
<p>London has over 13 million inhabitants.</p>
</div>
<p>The yellow background is added to demonstrate the footprint of the
DIV element.</p>
</body>
</html>
Marquee:
The <marquee> HTML element is used to insert a scrolling area of text.
You can control what happens when the text reaches the edges of its
content area using its attributes.
Attributes
behavior Deprecated
Sets how the text is scrolled within the marquee. Possible values
are scroll, slide and alternate. If no value is specified, the default value is scroll.
bgcolor Deprecated
direction Deprecated
Sets the direction of the scrolling within the marquee. Possible values
are left, right, up and down. If no value is specified, the default value is left.
height Deprecated
hspace Deprecated
loop Deprecated
Sets the number of times the marquee will scroll. If no value is specified, the default
value is −1, which means the marquee will scroll continuously.
scrollamount Deprecated
Sets the amount of scrolling at each interval in pixels. The default value is 6.
scrolldelay Deprecated
Sets the interval between each scroll movement in milliseconds. The default value is
85. Note that any value smaller than 60 is ignored and the value 60 is used instead
unless truespeed is specified.
truespeed Deprecated
vspace Deprecated
width Deprecated
Event handlers
onbounce Deprecated
Fires when the marquee has reached the end of its scroll position. It can only fire
when the behavior attribute is set to alternate.
onfinish Deprecated
Fires when the marquee has finished the amount of scrolling that is set by the loop
attribute. It can only fire when the loop attribute is set to some number that is greater
than 0.
onstart Deprecated
Methods
start() Deprecated
stop() Deprecated
Examples
<marquee>This text will scroll from right to left</marquee>
<marquee
direction="down"
width="250"
height="200"
behavior="alternate"
style="border:solid">
<marquee behavior="alternate">This text will bounce</marquee>
</marquee>
</head>
<body>
<pre>
#include < stdio.h >
#include < conio.h >
void main()
{
clrscr();
printf("Welcome to HTML");
getch();
}
</pre>
<br>
<p align=justify> hello mohit how are you</p>
<blockquote> <b>This text is inside blockquote tag. It is used for
indention. It is used to display important text with indention.
</blockquote>
</body>
</html>