Showing posts with label HTML Tags. Show all posts
Showing posts with label HTML Tags. Show all posts

Legend tag in html with examples





  1. The <legend> tag is used for labelling the fieldset element. 
  2. By using the <fieldset> tag and the <legend> tag, you can make your forms much easier to understand for your users. 
  3. The <fieldset> tag is used to group the form elements while the <legend> tag provides a label for the fieldset. 
  4. The <legend> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Legend</title>
     </head>
     <body>
     <fieldset>
     <legend>Employee Information</legend>
     EmpId:<input type="text"><br/>
     Name :<input type="text">
     </fieldset>
     </body>
     </html>
     

Demo :



In the above example, we have shown how to use legend element with fieldset element. We have created a simple form having two fields. We have included the form in the fieldset element which gives it a better look. The legend element renders as label or header for fieldset element.



Legend and Style :



<html>
<head>
<title>LegendStyle</title>
<style type="text/css">
legend
{
background-color:lightblue;
color:blue;
font-size:30px;
font-family:comic sans ms;
border:2px dotted black;
}
</style>
</head>
<body>
<fieldset>
<legend>Employee Information</legend>
EmpId:<input type="text"><br/>
Name :<input type="text">
</fieldset>
</body>
</html>

Demo :




In the above example, we have rendered a fieldset and legend element. Using the element selector we have also applied CSS to the legend element.



Legend and Javascript :



<html>
<head><title>LegendJavascript</title>
<style type="text/css">
legend
{
background-color:lightblue;
color:blue;
font-size:30px;
font-family:comic sans ms;
border:2px dotted black;
}
</style>
<script type="text/javascript">
function legend()
{
var elementFieldset=document.createElement("fieldset");
var elementLegend=document.createElement("legend");
var textLegend=document.createTextNode("Employee Information");
elementLegend.appendChild(textLegend);
elementFieldset.appendChild(elementLegend);
var elementLabel=document.createElement("Label");
var textLabel=document.createTextNode("Name:");
elementLabel.appendChild(textLabel);
var elementTextbox=document.createElement("input");
elementTextbox.setAttribute("type","text");
elementFieldset.appendChild(elementLabel);
elementFieldset.appendChild(elementTextbox);
document.getElementById("legend").appendChild(elementFieldset);
}
</script>
</head>
<body>
<div id="legend">
</div>
<input type="button" id="b1" value="Press" onclick="legend()"/>
</body>
</html>
     

Demo :





In the above example, on button click, we created <legend> element, created a text node and appended to <legend> element, further we appended <legend> element to <fieldset> along with label and textbox element. And finally, we appended the fieldset element to <div> element. Thus on button click we have created a small form having fieldset, legend and one field in it using javascript.



Label tag in html with examples





  1. The <label> tag is used for adding a label to a form control. 
  2. The <label> element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the <label> element, it toggles the control. 
  3. The for attribute of the <label> tag should be equal to the id attribute of the related element to bind them together.
  4. The <label> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Label</title>
     </head>
     <body>
     <label for="t1">Name:</label>
     <input type="text" id="t1"><br/>
     <label for="t2">Age:</label>
     <input type="text" id="t2">
     </body>
     </html>
     

Demo :




In the above example, we have rendered label control. We have also rendered text box corresponding to the label. The for attribute of label is set using the id attribute of the textbox in front.


Label and Style :



<html>
<head>
<title>LabelStyle</title>
<style type="text/css">
label
{
font-size:30px;
font-weight:bold;
font-family:comic sans  ms;
color:green;
}
</style>
</head>
<body>
<label for="t1">Name:</label>
<input type="text" id="t1"><br/>
<label for="t2">Age:</label>
<input type="text" id="t2">
</body>
</html>

Demo :




In the above example, we have rendered label control. We have applied CSS to the label text.



Label and Javascript :



<html>
<head><title>LabelJavascript</title>
<style type="text/css">
label
{
font-size:30px;
font-weight:bold;
font-family:comic sans  ms;
color:green;
}
</style>
<script type="text/javascript">
function label()
{
var element=document.createElement("label");
var text=document.createTextNode("Name:");
element.appendChild(text);
document.getElementById("span1").appendChild(element);
}
</script>
</head>
<body>
<span id="span1"></span><input type="text" id="t1"><br/>
<input type="button" id="b1" value="Press" onclick="label()"/>
</body>
</html>
     

Demo :




In the above example, we have rendered a text box and a button. On click of this button using JavaScript we have created a label element and appended in front of text box.



Italic tag in html with examples





  1. The HTML <i> tag renders text in italic style.
  2. The <i> tag defines a part of text in an alternate voice or mood. The <i> tag is typically displayed in italic type. 
  3. The <i> tag can be used to indicate a technical term, a phrase
  4. from another language, a thought, or a ship name, etc. 
  5. The <i> tag is supported in all major browsers.

Example :

     <html>
     <head>
     <title>I</title>
     </head>
     <body>
     <i>Welcome to 20Fingers2Brains.</i>
     </body>
     </html>
     

Demo :




In the above example, we have rendered italic element. It renders the text in italic style.


I and Style :



<html>
<head>
<title>IStyle</title>
<style type="text/css">
i
{
color:green;
font-size:30px;
margin-left:350px;
font-weight:bold
}
</style>
</head>
<body>
<i>Welcome to 20Fingers2Brains.</i>
</body>
</html>

Demo :




In the above example, we have rendered italic element and created a CSS class. We have also applied CSS to the rendered italic element.


Italic and Javascript :



<html>
<head><title>IJavascript2</title>
<style type="text/css">
i
{
color:green;
font-size:30px;
font-weight:bold
}
</style>
<script type="text/javascript">
function i()
{
var e=document.createElement("i");
var text=document.createTextNode("Welcome to 20Fingers2Brains.");
e.appendChild(text);
document.getElementById("i").appendChild(e);
}
</script>
</head>
<body>
<div id="i">
</div>
<input type="button" id="b1" value="Press" onclick="i()"/>
</body>
</html>
     

Demo :




In the above example, we have used javascript to create a italic tag and rendered it on UI.


hr tag in html with example





  1. The HTML <hr> tag is used for creating a horizontal rule. The <hr> element can be used to separate content in an HTML page. Most of the visual attributes for this tag have been deprecated in favor of style sheets. 
  2. In HTML, the <hr> tag has no end tag. 
  3. In XHTML, the <hr> tag must be properly closed, like this: <hr/>.
  4. The <hr> tag is supported in all major browsers. 

Example :

     <html>
     <head>
     <title>HR</title>
     </head>
     <body>
     <p>This is 20Fingers2Brains.</p>
     <hr/>
     <p>Powered by kk.</p>
     </body>
     </html>
     

Demo :




In the above example, we have rendered hr element between two paragraph elements. The hr tag is rendered as a horizontal line defining the partition.


HR and Style :



<html>
<head>
<title>HRStyle</title>
<style type="text/css">
hr
{
backfround-color:green;
height:15px;
}
</style>
</head>
<body>
<p>This is 20Fingers2Brains.</p>
<hr/>
<p>Powered by kk.</p>
</body>
</html>

Demo :




In the above example, we have rendered hr element. We have applied CSS to hr element using CSS class.


HR and Javascript :



<html>
<head><title>HRJavascript1</title>
<style type="text/css">
.hr
{
background-color:green;
height:15px;
}
</style>
<script type="text/javascript">
function hr()
{
document.getElementById("hr1").className="hr";
}    
</script>
</head>

<p>This is 20Fingers2Brains.</p>
<hr id="hr1"/>
<p>Powered by kk.</p>
<input type="button" id="b1" value="Press" onclick="hr()"/>
</body>
</html>
     

Demo :




In the above example, we have rendered a hr element, paragraph and button element. On click of button we are assigning the CSS class to hr element.



h1-h6 tag in html with examples





  1. The h1 to h6 tag is used for specifying headings. 
  2. There are 6 levels of headings (h1 - h6) with h1 the most important and h6 the least important. 
  3. Browsers typically render the various headings in different sizes  with h1 being the largest and h6 being the smallest. 
  4. The h1-h6 tags are supported in all major browsers.




Example :


     <html>
     <head>
     <title>I</title>
     </head>
     <body>
     <h1>This is 20Fingers2Brains.</h1>
     <h2>This is 20Fingers2Brains.</h2>
     <h3>This is 20Fingers2Brains.</h3>
     <h4>This is 20Fingers2Brains.</h4>
     <h5>This is 20Fingers2Brains.</h5>
     <h6>This is 20Fingers2Brains.</h6>
     </body>
     </html>
     

Demo :




In the above example, we have rendered all heading tags from h1 to h6. The h1 renders with larger font and the font-size decreases from h1 to h6.


h1-h6 and Style :


<html>
<head>
<title>h3-h6 Style</title>
<style type="text/css">
h1,h2,h3,h4,h5,h6
{
color:green;
font-size:30px;
margin-left:350px;
font-weight:bold
}
</style>
</head>
<body>
<h1>This is 20Fingers2Brains.</h1>
<h2>This is 20Fingers2Brains.</h2>
<h3>This is 20Fingers2Brains.</h3>
<h4>This is 20Fingers2Brains.</h4>
<h5>This is 20Fingers2Brains.</h5>
<h6>This is 20Fingers2Brains.</h6>
</body>
</html>


Demo :




In the above example, we have applied CSS to all heading elements rendered.


h1-h6 and Javascript :


<html>
<head><title>IJavascript2</title>
<style type="text/css">
h3
{
color:red;
font-weight:bold
}
</style>
<script type="text/javascript">
function h()
{
var eleh=document.createElement("h3");
var text=document.createTextNode("This is 99codingexamples.");
eleh.appendChild(text);
document.getElementById("h").appendChild(eleh);
}
</script>
</head>
<body>
<div id="h">
</div>
<input type="button" id="b1" value="Press" onclick="h()"/>
</body>
</html>
     

Demo :




In the above example, we have used javascript to create a h3 element and render it on UI. We have also applied CSS to it.


font tag in html with examples





  1. The <font> tag specifies the font face, font size, and font color of text.
  2. The HTML element <font> is an inline element. It is deprecated in HTML 4.0 in favor of cascading style sheets. The reason for this is simple: CSS (cascading style sheets) give you much more flexibility and many more styling options than the FONT element. There are six sizes that can be used with the FONT SIZE tag. 
  3. Font Size 7 is the largest, and Font Size 1 is the smallest. 
  4. The default size for type to display on a web page is Size 3. 
  5. The <font> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Font</title>
     </head>
     <body>
     <p><font size="20" color="green" face="comic sans ms">This is 99codingexamples.</font></p>
     <p><font size="25" color="red" face="courier">Powered by kk.</font&gt</p>
     </body>
     </html>
     

Demo :




In the above example, we have used font tag.


font and Style :


<html>
<head>
<title>FontStyle</title>
<style type="text/css">
font
{
color:green;
font-size:20px;
font-family:comic sans ms;
}
</style>
</head>
<body>
<p><font>This is 99codingexamples.</font></p>
<p><font>Powered by kk.</font></p>
</body>
</html>

Demo :




In the above example, we have rendered font element. We have also applied CSS to it.



fieldset tag in html with examples





  1. The <fieldset> tag is used for grouping related form elements. By using the fieldset tag and the legend tag, you can make your forms much easier to understand for your users. 
  2. The <fieldset> tag draws a box around the related elements.
  3. The <legend> tag defines a caption for the <fieldset> element. The <fieldset> is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Fieldset</title>
     </head>
     <body>
     <fieldset>
     <legend>Employee Information</legend>
     EmpId:<input type="text"><br/>
     Name :<input type="text">
     </fieldset>
     </body>
     </html>
     

Demo :




In the above example, we have used fieldset element to render a form like structure.


fieldset and Style :


<html>
<head>
<title>FieldsetStyle</title>
<style type="text/css">
fieldset
{
font-family:comic sans ms;
color:green;
font-weight:bold;
font-size:30px;
}
</style>
</head>
<body>
<fieldset>
<legend>Employee Information<legend>
EmpId:<input type="text"><br/>
Name :<input type="text">
</fieldset>
</body>
</html>

Demo :




In the above example, we have render the fieldset element. We have also applied the CSS to it.


fieldset and Javascript :


<html>
<head><title>FieldsetJavascript</title>
<style type="text/css">
fieldset
{
font-family:comic sans ms;
color:green;
font-weight:bold;
font-size:30px;
}
</style>
<script type="text/javascript">
function fieldset()
{
var element=document.createElement("fieldset");
var text=document.createTextNode("EMP-ID:");
var element2=document.createElement("input");
element2.setAttribute("type","text");
element.appendChild(text);
element.appendChild(element2);
document.getElementById("fieldset").appendChild(element);
}
</script>
</head>
<body>
<div id="fieldset">
</div>
<input type="button" id="b1" value="Press" onclick="fieldset()">
</body>
</html>
     

Demo :




In the above example, we have used javascript to create the fieldset element. On button click the fieldset element is created and rendered on the UI.



em tag in html with example





  1. The <em> tag is used to indicate emphasis (less emphasis than the HTML strong tag). 
  2. The <em> element is one of the phrase elements in HTML. The appearance of text enclosed within a <em> element is often rendered with an italic font.
  3. The <em> tag is supported in all major browsers.

Example :

     <html>
     <head>
     <title>EM</title>
     </head>
     <body>
     I love <em>Football.</em>
     This is <em>20Fingers2Brains</em>
     </body>
     </html>
     

Demo :





In the above example, we have rendered em element. The em element is rendered in italics style.



em and Style :



<html>
<head>
<title>EMStyle</title>
<style type="text/css">
em
{
color:green;
font-size:20px;
font-family:comic sans ms;
}
</style>
</head>
<body>
I love <em>Football.</em><br/>
This is <em>20Fingers2Brains</em>
</body>
</html>

Demo :





In the above example, we have rendered em tag. We have also applied CSS to it.



em and Javascript :



<html>
<head><title>EMJavascript</title>
<style type="text/css">
</style>
<script type="text/javascript">
function em()
{
var element=document.createElement("em");
var text=document.createTextNode("This is Emphasized effect.");
element.appendChild(text);
document.getElementById("em").appendChild(element);
}
</script>
</head>
<body>
<div id="em">
</div>
<input type="button" id="b1" value="Press" onclick="em()">
</body>
</html>
     

Demo :





In the above example, we have rendered em tag on button click. 



dt tag in html with examples






  1. The <dt> tag is used for specifying a definition term in a definition list.
  2. A definition list is similar to other lists but in a definition list, each list item contains two entries; a term and a description. 
  3. The <dt> tag is used in conjunction with <dl> (defines the definition list) and <dd> (describes the item in the list). 
  4. The <dt> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>DT</title>
     </head>
     <body>
     <dl>
     <dt>Fruits</dt>
     <dd>Mango</dd>
     <dd>Grapes</dd>
     <dt>Vegetables</dt>
     <dd>Potato</dd>
     <dd>Tomato</dd>
     </dl>
     </body>
     </html>
     

Demo :





In the above example, we have rendered dt tag.



dt and Style :



<html>
<head>
<title>DTStyle</title>
<style type="text/css">
dt
{
font-family:comic sans ms;
color:green;
width:400px;
text-align:center;
}
</style>
</head>
<body>
<dl>
<dt>Fruits</dt>
<dd>Mango</dd>
<dd>Grapes</dd>
<dt>Vegetables</dt>
<dd>Potato</dd>
<dd>Tomato</dd>
</dl>
</body>
</html>

Demo :





In the above example, we have rendered dt element. We have also applied CSS to it.



dl tag in html with examples






  1. The <dl> tag defines a definition list. A list is composed by terms (HTML dt tag) and descriptions (HTML dd tag). 
  2. A definition list is similar to other lists but in a definition list, each list item contains two entries; a term and a description.
  3. The <dl> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>DL</title>
     </head>
     <body>
     <dl>
     <dt>Fruits</dt>
     <dd>Mango</dd>
     <dd>Grapes</dd>
     <dt>Vegetables</dt>
     <dd>Potato</dd>
     <dd>Tomato</dd>
     </dl>
     </body>
     </html>
     

Demo :





In the above example, we have render the dl element.



dl and style :




<html>
<head>
<title>DLStyle</title>
<style type="text/css">
dl
{
font-family:comic sans ms;
color:green;
width:400px;
text-align:center;
}
</style>
</head>
<body>
<dl>
<dt>Fruits</dt>
<dd>Mango</dd>
<dd>Grapes</dd>
<dt>Vegetables</dt>
<dd>Potato</dd>
<dd>Tomato</dd>
</dl>
</body>
</html>


Demo :



div tag in html with example






  1. The <div> tag defines a division or a section in an HTML document. 
  2. Using <div> tag, you can group large sections of HTML elements together and format them with CSS. 
  3. The <div> tag can contain almost any other element. Browsers always place a line break before and after the <div> element. 
  4. The <div> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Div</title>
     </head>
     <body>
     <div id="div1">
     <p>This is content of div1.</p>
     </div>
     <div id="div2">
     <p>This is content of div2.</p>
     </div>
     </body>
     </html>
     

Demo :





In the above example, we have created two divs. We have included paragraph element inside the div element.




div and Style :



<html>
<head>
<title>DivStyle</title>
<style type="text/css">
div
{
font-family:comic sans ms;
color:green;
display:block;
border-style:ridge;
}
</style>
</head>
<body>
<div id="div1">
<p>This is content of div1.</p>
</div>
<div id="div2">
<p>This is content of div2.</p>
</div>
</body>
</html>

Demo :





In the above example, we have rendered two divs and applied CSS to them. We have use element selector to apply CSS.




div and Javascript :




<html>
<head><title>DivJavascript</title>
<style type="text/css">
div
{
border:solid 1px black;
}
</style>
<script type="text/javascript">
function div()
{
var element=document.createElement("div");
var text=document.createTextNode("This is div effect.");
element.appendChild(text);
element.setAttribute("class","div");
document.getElementById("div").appendChild(element);
}
</script>
</head>
<body>
<div id="div">
</div>
<input type="button" id="b1" value="Press" onclick="div()">
</body>
</html>
     

Demo :






In the above example, we have used javascript to render a div. The div is created on button click, CSS class is also assigned and it is appended to the existing div.



dir tag in html with examples






  1. The <dir> tag is used to create a directory list of computer files and programs.
  2. The <dir> tag is officially deprecated effective with HTML 4.0.
  3. Instead, you are now to use the unordered list ul tag.
  4. The dir tag is used to create a directory list of computer files and programs.
  5. The dir tag must be used with the <li> tag which places a bullet before each line of text just like it does for the <ul> tag. You can create a nested (indented) directory list by placing <dir> tags between another opening and closing pair of <dir> tags.
  6. In some browsers, the bullet becomes a circle for the nested list. 
  7. The <dir> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Dir</title>
     </head>
     <body>
     <dir>
     <li> html_lists</li>
     <dir>
     <li> kk.html</li>
     <li> hh.html</li>
     <li> ps.html</li>
     </dir>
     <li> html_events
     <dir>
     <li> td_onclick.html</li>
     <li> rt_ondblclick.html</li>
     </dir>
     </dir>
     </body>
     </html>
     

Demo :





In the above example, we have rendered dir element.



dir and Style :



<html>
<head>
<title>DirStyle</title>
<style type="text/css">
dir
{
font-family:comic sans ms;
color:green;
background-image:url("p1.jpg");
}
</style>
</head>
<body>
<dir>
<li> html_lists
<dir>
<li> kk.html
<li> hh.html
<li> ps.html
</dir>
<li> html_events
<dir>
<li> td_onclick.html
<li> rt_ondblclick.html
</dir>
</dir>
</body>
</html>


Demo :





In the above example, we have applied CSS to die element.



dfn tag in html with examples





  1. The HTML <dfn> tag is used for indicating a definition. The <dfn> tag surrounds the word/term being defined. 
  2. The closing tag for the <dfn> Tag is required. 
  3. This element takes the width of the text. The <dfn> tag is supported in all major browsers.

Example :

     <html>
     <head>
     <title>DFN</title>
     </head>
     <body>
     <p>This is text without code effect.</p>
     <dfn>This is text with dfn effect.</dfn>
     </body>
     </html>
     

Demo :





In the above example, we have rendered dfn element. The dfn element is rendered in italic style by default.



dfn and Style :



<html>
<head>
<title>DFNStyle</title>
<style type="text/css">
dfn
{
font-family:comic sans ms;
color:green;
}
</style>
</head>
<body>
<p>This is text without code effect.</p>
<dfn>This is text with dfn effect.</dfn>
</body>
</html>


Demo :





In the above example, we have rendered dfn tag. We have applied CSS to dfn element using element selector in CSS.




dfn and Javascript :



<html>
<head><title>DFNJavascript</title>
<script type="text/javascript">
function dfn()
{
var element=document.createElement("dfn");
var text=document.createTextNode("This is dfn effect.");
element.appendChild(text);
document.getElementById("dfn").appendChild(element);
}
</script>
</head>
<body>
<div id="dfn">
</div>
<input type="button" id="b1" value="Press" onclick="dfn()">
</body>
</html>
     

Demo :





In the above example, we have created a button. On click of button, we are creating and rendering a dfn element using javascript.



del tag in html with examples





  1. The <del> tag is used for markup of deleted text. Markup of deleted text can be useful in determining differences between multiple versions of the same document.
  2. Browsers will normally strike a line through deleted text and underline inserted text. 
  3. The <del> is supported in all major browsers.

Example :

     <html>
     <head>
     <title>DEL</title>
     </head>
     <body>
     <p style="font-size:30px;">HTML is <del>hard</del> easy to learn.</p>
     </body>
     </html>
     

Demo :




In the above example, we have shown how to use del tag. the del tag renders text with crossed line.



del and Style :



<html>
<head>
<title>DELStyle</title>
<style type="text/css">
del
{
font-size:50px;
font-family:comic sans ms;
color:green;
}
</style>
</head>
<body>
<p style="font-size:20px;">HTML is <del>hard</del> easy to learn.</p>
</body>
</html>

Demo :





In the above example, we have rendered del element with CSS applied to it using element selector.



del and Javascript :



<html>
<head><title>DELJavascript</title>
<style type="text/css">
del
{
font-size:30px;
font-family:comic sans ms;
color:green;
}
</style>
<script type="text/javascript">
function del()
{
var element=document.createElement("del");
var text=document.createTextNode("hard");
element.appendChild(text);
document.getElementById("del").appendChild(element);
}
</script>
</head>
<body>
<p>HTML is 
<span id="del"></span> easy to learn.</p>
<input type="button" id="b1" value="Press" onclick="del()">
</body>
</html>
     

Demo :





In the above example, we have used javascript to render the del element. On button click, the dele element is created and is appended to the text.



dd tag in html with examples






  1. The HTML <dd> tag is used for specifying a definition description in a definition list.
  2. A definition list is similar to other lists but in a definition list, each list item contains two entries; a term and a description.
  3. Inside a <dd> tag you can put paragraphs, line breaks, images, links, lists,etc.
  4. The <dd> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>DD</title>
     </head>
     <body>
     <dl>
     <dt>Fruits</dt>
     <dd>Mango</dd>
     <dd>Grapes</dd>
     <dt>Vegetables</dt>
     <dd>Potato</dd>
     <dd>Tomato</dd>
     </dl>
     </body>
     </html>
     

Demo :




In the above example, we have used dd tag to render list.



dd and Style :



<html>
<head>
<title>DDStyle</title>
<style type="text/css">
dd
{
font-family:comic sans ms;
color:green;
width:400px;
text-align:center;
}
</style>
</head>
<body>
<dl>
<dt>Fruits</dt>
<dd>Mango</dd>
<dd>Grapes</dd>
<dt>Vegetables</dt>
<dd>Potato</dd>
<dd>Tomato</dd>
</dl>
</body>
</html>

Demo :





In the above example, we have applied style to dd elements using element selector.

comment tag in html with example






  1. The comment tag is used to insert comments in the source code.
  2. Comments are not displayed in the browsers.
  3. You can use comments to explain your code, which can help you when you edit the source code at a later date. This is especially useful if you have a lot of code.
  4. The comment tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Anchor</title>
     </head>
     <body>
     <!--This is a Comment. Comments are not visible on browser.-->
     <p>This is my simple example for comment.</p>
     </body>
     </html>
     

Demo :




In the above example, we have used comment tag. The text inside the comment tag is not visible on browser. 



colgroup tag in html with examples






  1. The <colgroup> tag is used for specifying properties for a group of columns within a table.
  2. If you need to apply different properties to a column within a colgroup, you can use the <col> tag within the <colgroup> tag.
  3. The <colgroup> tag can only be used inside a <table> element.
  4. The <colgroup> is supported in all major browsers.


Example :

     <html>
     <head>
     <title>ColGroup</title>
     </head>
     <body>
     <table border="1" align="center" width="40%">
     <caption>Employee Details</caption>
     <colgroup span="2" style="background-color:gray;color:silver;">
     </colgroup>
     <colgroup style="background-color:orange;color:red;">
     </colgroup>
     <tr>
     <th>EmpId</th>
     <th>Name</th>
     <th>Department</th>
     </tr>
     <tr>
     <td>1001</td>
     <td>hitesh</td>
     <td>Testing</td>
     </tr>
     <tr>
     <td>1002</td>
     <td>Sahil</td>
     <td>DBA</td>
     </tr>
     </table>
     </body>
     </html>
     

Demo :





In the above example, we have used colgroup tag to apply style to specific columns.



ColGroup and Style :



<html>
<head>
<title>ColGroupStyle</title>
<style type="text/css">
#k1
{
background-color:skyblue;
color:blue;
}
#k2
{
background-color:yellow;
color:red;
}
</style>
</head>
<body>
<table border="1" align="center" width="40%">
<caption>Employee Details</caption>
<colgroup id="k1" span="2">
</colgroup>
<colgroup id="k2">
</colgroup>
<tr>
<th>EmpId</th>
<th>Name</th>
<th>Department</th>
</tr>
<tr>
<td>1001</td>
<td>hitesh</td>
<td>Testing</td>
</tr>
<tr>
<td>1002</td>
<td>Sahil</td>
<td>DBA</td>
</tr>
</table>
</body>
</html>

Demo :





In the above example, we have created two style classes and assigned to table columns using id selector.



col tag in html with examples






  1. The <col> tag is used for specifying column properties for each column within a colgroup.
  2. You would normally only use this tag if the values for each column is different. Otherwise, you can specify the properties as part of the colgroup tag.
  3. The <col> tag can only be used inside a <table> or a <colgroup> element. Add the style attribute to the <col> tag, and let CSS take care ofbackgrounds, width and borders.
  4. The <col> is supported in all major browsers.


Example :

     <html>
     <head>
     <title>COL</title>
     </head>
     <body>
     <table border="1" align="center" width="40%">
     <caption>Employee Details</caption>
     <colgroup>
     <col span="2" style="background-color:gray;color:silver;">
     <col style="background-color:orange;color:red;">
     </colgroup>
     <tr>
     <th>EmpId</th>
     <th>Name</th>
     <th>Department</th>
     </tr>
     <tr>
     <td>1001</td>
     <td>hitesh</td>
     <td>Testing</td>
     </tr>
     <tr>
     <td>1002</td>
     <td>Sahil</td>
     <td>DBA</td>
     </tr>
     </table>
     </body>
     </html>
     

Demo :





In the above example, we have used col tag to apply style to specific columns.



Col and Style :



<html>
<head>
<title>ColStyle</title>
<style type="text/css">
#k1
{
background-color:skyblue;
color:blue;
}
#k2
{
background-color:yellow;
color:red;
}
</style>
</head>
<body>
<table border="1" align="center" width="40%">
<caption>Employee Details</caption>
<colgroup>
<col id="k1" span="2">
<col id="k2">
</colgroup>
<tr>
<th>EmpId</th>
<th>Name</th>
<th>Department</th>
</tr>
<tr>
<td>1001</td>
<td>hitesh</td>
<td>Testing</td>
</tr>
<tr>
<td>1002</td>
<td>Sahil</td>
<td>DBA</td>
</tr>
</table>
</body>
</html>

Demo :





In the above example, we have created two style classes and assigned to table columns using id selector.

code tag in html with examples





  1. The HTML <code> tag is used for indicating a piece of code.
  2. The <code> tag surrounds the code being marked up.
  3. The <code> is rendered in a fixed width font.
  4. Similar tags are kbd for specifying keyboard entry text, samp for specifying sample output from a computer program, pre for defining preformatted text, and var for defining a variable.
  5. The <code> tag is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Code</title>
     </head>
     <body>
     <p>This is text without cite effect.</p>
     <code>This is text with cite effect.</code><br/>
     <code>var myArray=new Array(3);</code>
     </body>
     </html>
     

Demo :





In the above example, we have rendered code tag. The text inside the code renders like a piece of code.



Code And Style :



<html>
<head>
<title>CodeStyle</title>
<style type="text/css">
code
{
color:blue;
font-size:20px;
}
</style>
</head>
<body>
<p>This is text without code effect.</p>
<code>This is text with code effect.</code>
</body>
</html>

Demo :




In the above example, we have used CSS with the code tag.



Code and Javascript :



<html>
<head><title>CodeJavascript</title>
<script type="text/javascript">
function code()
{
var element=document.createElement("code");
var text=document.createTextNode("This is code effect.");
element.appendChild(text);
document.getElementById("code").appendChild(element);
}
</script>
</head>
<body>
<div id="code">
</div>
<input type="button" id="b1" value="Press" onclick="code()">
</body>
</html>
     

Demo :





In the above example, we have used javascript to create a code tag and render it on UI.

cite tag in html with examples






  1. The HTML <cite> tag is used for indicating a citation. It's rendered in italic text in most browsers.
  2. The <cite> tag is supported in all major browsers.

Example :

     <html>
     <head>
     <title>Cite</title>
     </head>
     <body>
     <p>This is text without cite effect.</p>
     <cite>This is text with cite effect.</cite>
     </body>
     </html>
     

Demo :





In the above example, we have rendered a paragraph and cite element. The cite element is rendered in italic font.



Cite and Style :



<html>
<head>
<title>CiteStyle</title>
<style type="text/css">
cite
{
font-family:comic sans ms;
color:blue;
font-size:20px;
}
</style>
</head>
<body>
<p>This is text without cite effect.</p>
<cite>This is text with cite effect.</cite>
</body>
</html>

Demo :





In the above example, we have rendered a cite element. We have applied CSS to it.



Cite and Javascript :



<html>
<head><title>CiteJavascript</title>
<script type="text/javascript">
function cite()
{
var element=document.createElement("cite");
var text=document.createTextNode("This is cite effect.");
element.appendChild(text);
document.getElementById("cite").appendChild(element);
}
</script>
</head>
<body>
<div id="cite">
</div>
<input type="button" id="b1" value="Press" onclick="cite()">
</body>
</html>
     

Demo :




In the above example, we have rendered a button. On click of this button the cite element is created and rendered.