br tag in html with examples






  1. The br tag is used to create a one line break. 
  2. In html the br tag is written as <br />. 
  3. When a user use the br tag in a sentence, the sentence will be automatically started in a new line.
  4. The br tag inserts a single line break.
  5. The br tag is an empty tag which means that it has no end tag. In HTML the br tag has no end tag. In XHTML the br tag must be properly closed, like this:  <br />
  6. The br is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Br</title>
     </head>
     <body>
     <p>This <br> is <br> 99codingexamples.</p>
     <p>You will find everything <br> you need!!</p>
     </body>
     </html>
     

Demo :





In the above example, we have used br tag. In the above example wherever we have used br tag, the sentence starts from the next line.



BR tag and Javascript :



<html>
<head><title>Br</title>
<script type="text/javascript">
function br()
{
var ins='This <br/>is<br/>99codingexsmples';
document.getElementById("br").innerHTML=ins;
}
</script>
</head>
<body>
<p id="br"></p>
<input type="button" id="b1" value="Press" onclick="br()">
</body>
</html>
     

Demo :





In the above example, we have selecting the paragraph element using javascript and appending text in it. We have also appended br tag in the text. When the text is rendered, each word in rendered on the next line.



0 comments:

Post a Comment