bold tag in html with example


  1. The bold <b> tag is used to place your text into boldface. The <b> element is not deprecated, but it is not as accessible as it's counterpart the <strong> element. 
  2. Many browsers render the <strong> tag in the same fashion as the <b> tag. 
  3. The <strong> tag is more correct for standards-based XHTML.
  4. If you can't use the <strong> element, then you should consider using the CSS font-weight.
  5. The <b> is supported in all major browsers. property.




Example 1 :


     
     <html>
     <head>
     <title>Br</title>
     </head>
     <body>
     Plain Text: This is plain text.<br/>
     Bold Text: <b>This is not.</b>
     </body>
     </html>
     

Demo :



In the above example we have rendered plain text and bold text, to show what bold tag can make difference.



Example 2 : Bold element and Style



<html>
<head>
<title>BStyle</title>
<style type="text/css">
#kk
{
font-family:comic sans ms;
font-size:30px;
color:green;
}
</style>
</head>
<body>
Plain Text: This is plain text.
Bold Text:<b id="kk">This is not.</b>
</body>
</html>


Demo :




In the above example, we have renedere one plain text and one bold text. We have applied CSS class to bold text.


Example 3 : Bold and jQuery




<html>
<head><title>B</title>
<script type="text/javascript">
    $(document).ready(function () {
        $("#b1").click(function () {
            var ins = "This is 2 Brains 20 fingers";
            $("#b").html(ins);
        });
    });
</script>
</head>
<body>
<p id="b"></p>
<input type="button" id="b1" value="Press" />
</body>
</html>
     

Demo :



In the above example, on button click we are preparing a html syntax for bold element in string and appending to the paragraph element using html() method.


0 comments:

Post a Comment