HTML Formatting: 1) Bold Text
HTML Formatting: 1) Bold Text
HTML Formatting: 1) Bold Text
HTML Formatting is a process of formatting text for better look and feel. HTML
provides us ability to format text without using CSS. There are many formatting tags in
HTML. These tags are used to make text bold, italicized, or underlined. There are almost
14 options available that how text appears in HTML and XHTML.
Element Description
name
<b> This is a physical tag, which is used to bold the text written between
it.
<strong> This is a logical tag, which tells the browser that the text is
important.
<big> This tag is used to increase the font size by one conventional unit.
<small> This tag is used to decrease the font size by one unit from base font
size.
1) Bold Text
HTML<b> and <strong> formatting elements
The HTML <b> element is a physical tag which display text in bold font, without any
logical importance. If you write anything within <b>............</b> element, is shown in
bold letters.
<html>
<body>
<h1>Explanation of formatting element</h1>
<b>This is an important content and this is normal content</b>
</body>
</html>
2) Italic Text
HTML <i> and <em> formatting elements
The HTML <i> element is physical element, which display the enclosed content in italic
font, without any added importance. If you write anything within <i>............</i> element,
is shown in italic letters.
<html>
<body>
<h1>Explanation of formatting element</h1>
<i>This is an important content and this is normal content</i>
</body>
</html>
3) Underlined Text
If you write anything within <u>.........</u> element, is shown in underlined text.
<html>
<body>
<h1>Explanation of formatting element</h1>
<u>This is an important content and this is normal content</u>
</body>
</html>
4) Strike Text
Anything written within <strike>.......................</strike> element is displayed with
strikethrough. It is a thin line which cross the statement.
<html>
<body>
<h1>Explanation of formatting element</h1>
<strike>This is an important content and this is normal content</strike>
</body>
</html>
5) Superscript Text
If you put the content within <sup>..............</sup> element, is shown in superscript;
means it is displayed half a character's height above the other characters.
<p>Hello <sup>Write Your First Paragraph in superscript.</sup></p>
<html>
<body>
<h1>Explanation of formatting element</h1>
Hello <sup> 2 </sup>
</body>
</html>
6) Subscript Text
If you put the content within <sub>..............</sub> element, is shown in subscript ;
means it is displayed half a character's height below the other characters.
<p>Hello <sub>Write Your First Paragraph in subscript.</sub></p>
<html>
<body>
<h1>Explanation of formatting element</h1>
Hello <sub> 2 </sub>
</body>
</html>
7) Larger Text
If you want to put your font size larger than the rest of the text then put the content
within <big>.........</big>. It increase one font size larger than the previous one.
<p>Hello <big>Write the paragraph in larger font.</big></p>
<html>
<body>
<h1>Explanation of formatting element</h1>
<big>This is an important content and this is normal content</big>
</body>
</html>
8) Smaller Text
If you want to put your font size smaller than the rest of the text then put the content
within <small>.........</small>tag. It reduces one font size than the previous one.
<p>Hello <small>Write the paragraph in smaller font.</small></p>
<html>
<body>
<h1>Explanation of formatting element</h1>
<small>This is an important content and this is normal content</small>
</body>
</html>
HTML Image
HTML img tag is used to display image on the web page. HTML img tag is an empty
tag that contains attributes only, closing tags are not used in HTML image element.
<img src="good_morning.jpg"/>
1) src
It is a necessary attribute that describes the source or path of the image. It instructs the
browser where to look for the image on the server.
2) width
It is an optional attribute which is used to specify the width to display the image. It is
not recommended now. You should apply CSS in place of width attribute.3
3) height
It h3 the height of the image. The HTML height attribute also supports iframe, image
and object elements. It is not recommended now. You should apply CSS in place of
height attribute.
<html>
<body>
<h2>HTML image example with height and width</h2>
<img src="c: /images/animal.jpg" height="180" width="300" alt="animal
image">
</body>
</html>
HTML Anchor
The HTML anchor tag defines a hyperlink that links one page to another page. It can
create hyperlink to other web page as well as files, location, or any URL. The "href"
attribute is the most important attribute of the HTML a tag. and which links to
destination page or URL.
Program:
<html>
<body>
</body>
</html>
HTML Table
HTML table tag is used to display data in tabular form (row * column). There can be
many columns in a row.
We can create a table to display data in tabular form, using <table> element, with the
help of <tr> , <td>, and <th> elements.
In Each table, table row is defined by <tr> tag, table header is defined by <th>, and
table data is defined by <td> tags.
<html>
<body>
<table>
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
<tr><td>James</td><td>William</td><td>80</td></tr>
<tr><td>Swati</td><td>Sironi</td><td>82</td></tr>
<tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
</table>
</body>
</html>
<body>
<table border="1">
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
<tr><td>James</td><td>William</td><td>80</td></tr>
<tr><td>Swati</td><td>Sironi</td><td>82</td></tr>
<tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
</table>
</body>
</html>
HTML Lists
HTML Lists are used to specify lists of information. All lists may contain one or more list
elements. There are three different types of HTML lists:
<html>
<body>
<ol>
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ol>
</body>
</html>
HTML Unordered List or Bulleted List
In HTML Unordered list, all the list items are marked with bullets. It is also known as
bulleted list also. The Unordered list starts with <ul> tag and list items start with the
<li> tag.
<html>
<body>
<ul>
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ul>
</body>
</html>
The definition list is very appropriate when you want to present glossary, list of terms or
other name-value list.
<html>
<body>
<dl>
<dt>Aries</dt>
<dt>Bingo</dt>
<dt>Leo</dt>
<dt>Oracle</dt>
</dl>
</body>
</html>
HTML Form
An HTML form is a section of a document which contains controls such as text fields,
password fields, checkboxes, radio buttons, submit button, menus etc.
An HTML form facilitates the user to enter data that is to be sent to the server for
processing such as name, email address, password, phone number, etc. .
Tag Description
Syntax:
<form>
//Form elements
</form>
Example:
<html>
<body>
<form>
Enter your name <br>
<input type="text" name="username">
</form>
</body>
</html>
<html>
<body>
<form>
First Name: <input type="text" name="firstname"/> <br/>
Last Name: <input type="text" name="lastname"/> <br/>
</form>
</body>
</html>
HTML <textarea> tag in form
The <textarea> tag in HTML is used to insert multiple-line text in a form. The size of
<textarea> can be specify either using "rows" or "cols" attribute
Example:
<html>
<head>
<title>Form in HTML</title>
</head>
<body>
<form>
Enter your address:<br>
<textarea rows="2" cols="20"></textarea>
</form>
</body>
</html>
<html>
<body>
<form>
<label for="password">Password: </label>
<input type="password" id="password" name="password"/> <br/>
</form>
</body>
</html>
If you use one name for all the radio buttons, only one radio button can be selected at a
time.
Using radio buttons for multiple options, you can only choose a single option at a time.
<html>
<body>
<form>
<label for="gender">Gender: </label>
<input type="radio" id="gender" name="gender" value="male"/>Male
<input type="radio" id="gender" name="gender" value="female"/>Female <br/>
</form>
</body>
</html>
Checkbox Control
The checkbox control is used to check multiple options from given checkboxes.
<html>
<body>
<form>
Hobby:<br>
<input type="checkbox" id="cricket" name="cricket" value="cricket"/>
<label for="cricket">Cricket</label> <br>
<input type="checkbox" id="football" name="football" value="football"/>
<label for="football">Football</label> <br>
<input type="checkbox" id="hockey" name="hockey" value="hockey"/>
<label for="hockey">Hockey</label>
</form>
</body>
</html>
Syntax:
<input type="submit" value="submit">
The value attribute can be anything which we write on button on web page.
Example:
<html>
<body>
<form>
<label for="name">Enter name</label><br>
<input type="text" id="name" name="name"><br>
<label for="pass">Enter Password</label><br>
<input type="Password" id="pass" name="pass"><br>
<input type="submit" value="submit">
</form>
</body>
</html>
Example:
<html>
<body>
<form>
<fieldset>
<legend>User Information:</legend>
<label for="name">Enter name</label><br>
<input type="text" id="name" name="name"><br>
<label for="pass">Enter Password</label><br>
<input type="Password" id="pass" name="pass"><br>
<input type="submit" value="submit">
</fieldset>
</form>
</body>
</html>
FORM EXAMPLE:
<html>
<body>
<form">
<table>
<tr>
<td class="tdLabel"><label for="register_name" class="label">Enter name:</label></td>
<td><input type="text" name="name" value="" id="register_name"
style="width:160px"/></td>
</tr>
<tr>
<td class="tdLabel"><label for="register_password" class="label">Enter
password:</label></td>
<td><input type="password" name="password" id="register_password"
style="width:160px"/></td>
</tr>
<tr>
<td class="tdLabel"><label for="register_email" class="label">Enter Email:</label></td>
<td
><input type="email" name="email" value="" id="register_email" style="width:160px"/></td>
</tr>
<tr>
<td class="tdLabel"><label for="register_gender" class="label">Enter Gender:</label></td>
<td>
<input type="radio" name="gender" id="register_gendermale" value="male"/>
<label for="register_gendermale">male</label>
<input type="radio" name="gender" id="register_genderfemale" value="female"/>
<label for="register_genderfemale">female</label>
</td>
</tr>
<tr>
<td class="tdLabel"><label for="register_country" class="label">Select
Country:</label></td>
<td><select name="country" id="register_country" style="width:160px">
<option value="india">india</option>
<option value="pakistan">pakistan</option>
<option value="africa">africa</option>
<option value="china">china</option>
<option value="other">other</option>
</select>
</td>
</tr>
<tr>
<td colspan="2"><div align="right"><input type="submit" id="register_0"
value="register"/>
</div></td>
</tr>
</table>
</form>
</body>
</html>