HTML Attributes and HTML Comments ( PART-02 )

Published by StudyMuch on

HTML Attributes and Comments

In this tutorial you will learn the HTML Attribute and HTML Comments with all the programming examples.

1.    HTML Attributes

2.    HTML Comments

HTML Attribute

HTML attribute are used to add more information to an HTML element. 

Important things to remember about HTML attribute-

·       HTML attribute are found in HTML tag.

·       HTML element can have multiple attribute.

·       HTML attribute only appear in start tag. It is never used in end tag.

Some important attribute given below here-

List of HTML Attribute.

ATTRIBUTES DESCRIPTION
lang We use this attribute to define the language of HTML file.
href Specific the URL, for a link.
 title Specific extra information about an element.
style Style attribute is used in inline CSS stylefor an element.
id Specific a unique id for an element.
value Specific the value for an input element.
class Specific a unique id for an element.
disabled Specific that an input element should be disabled.
src Used for URL of an image.

Here we are using some attribute with an example. Seeing which you can easily understand.

1.    Example of lang Attribute;

1.      <!DOCTYPE html>
2.      <html lang=”en”>
3.      <head>
4.          <title>Studyons.com</title>
5.      </head>
6.      <body>
7.          <P>Hello World</P>
8.      </body>
9.      </html>

Here we used the lang attribute to define the language of an HTML file.        
The language are define above in English, <html lang “en”>

2.    Example of href Attribute;

     <!DOCTYPE html>
      <html lang=”en”>
      <head>
          <title>Studyons.com</title>
      </head>
      <body>

          <a href=”https://www.studyons.com”>Visit StudyMuch.in</a>
   </body>
   </html>

Here we used the href attribute to specific the URL (https://www.studymuch.in) for a link. Link are define using anchor <a> element.
On the example above we used the href attribute to display URL.

3. Example of style Attribute;

<!DOCTYPE html>
<html lang=”en”>
    <style type=”text/css”>
    body{color: brown; font-size: 40px;}
    </style>
<head>
    <title>Studyons.com</title>
</head>
<body>
    <a href=”https://www.studyons.com”>Visit StudyOns.Com</a>
</body>
</html>

On the example above we created body using the <body> element and change style using <style> attribute. Here we used style attribute to change its color and font size.

4. Example of src Attribute;

<!DOCTYPE html>
<html lang=”en”>
    <style type=”text/css”>
    body{color: brown; font-size: 40px;}
    </style>
<head>
    <title>Studyons.com</title>
</head>
<body>
    <img src=”shubham.jpg”/>
</body>
</html>

In the above example we use the src attribute to display the image.

HTML Comment

HTML comments are text, sentences or phrase on the HTML file, They are only show in coding file not display output in browser. here we know  how to write HTML comments?                                                                                 
An HTML comments starts with <!– and end with –>.It look like this type:            <!–Studymuch.in–>

Example of HTML Comment;

<!DOCTYPE html>
<html lang=”en”>
    <style type=”text/css”>
    p {color: brown; font-size: 20px;}
    </style>
<head>
    <!–This is the tytle of HTML file–>
    <title>Studyons.com</title>
</head>
<body>
    <!–This is Heading 1–>
    <h1>Studyons Learning</h1>
    <!–This is Paragraph–>
    <P>This is an Educational website</P>
</body>
</html>


On the example given above you learn how to write comments on HTML file. You also put single and multiple line of comments on HTML file, between start tag and end tag and you also put comments outside start and end tag. So, in this tutorial we learned two main things are HTML Attribute and HTML Comments. We will learn a new things in next tutorial.

  • what is an attribute in html,
  • html elements and attributes,
  • html attributes example,
  • elements in html,
  • html attributes list,
  • html attributes list with examples,
  • html tags and attributes pdf,
  • html elements list,
  • HTML comments example,
  • What is HTML,

6 Comments

doxycyclinevurne · December 25, 2022 at 11:59 am

I’m not sure where you’re getting your info, but good topic. I needs to spend some time learning much more or understanding more.
Thanks for great information I was looking for this info for my mission.

antibioticsK · January 10, 2023 at 12:04 am

Thanks for wonderful information I was looking for this information for my mission.

Maudie Schwentker · May 7, 2023 at 11:12 am

Spot on with this write-up, I truly believe this site requirements additional consideration. I’ll likely to end up again to see additional, thank you for that info.

Elliot Segar · May 21, 2023 at 1:49 pm

what’s up, puissant blog on oleaginous loss. analogous helped.

Alesha Zuleger · May 21, 2023 at 10:10 pm

what’s happening, chief blog on unctuous loss. said helped.

Torri Bok · July 4, 2023 at 3:57 pm

what’s up, regal blog on oleaginous loss. this helped.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *