Sunday, February 1, 2015

Create Your Own HTML Tags



You might be programming with html and may be thinking how to create your own html tags  to use in html code. This is a very easy task. First you need to define a name for your tag. You should be careful not to use any html reserved words. Assume you have named your tag name as mytag. Use it in the html code as a normal tag.(write opening tag and closing tag)

<mytag>

</mytag>
 Now you need to provide attributes for the tag that you have defined. You can add these attributes using CSS.
<style type="text/css">
     mytag{
            background-color: lawngreen;
            padding : 10px;
            font-style : italic; 
          }
</style>
Now you can use your tag as a normal html tag and  use it in your html code.
Complete code :
<!DOCTYPE html>
<html>
    <head>
         <style type="text/css">
             mytag{
                 background-color: lawngreen;
                 padding: 10px;
                 font-style: italic;
                  }
         </style>
    </head>
    <body>
        <mytag>
            hello world
        </mytag>
    </body>
</html> 

No comments:

Post a Comment