Basic Elements - Learn HTML - Free Interactive HTML Tutorial

Image
Basic Elements The use of basic HTML Tags.. Coding.... <!DOCTYPE html> <html> <head> <title>Example page</title> </head> <body> <h1>Heading 1</h1> <h2>Heading 1</h2> <h3>Heading 1</h3> <h4>Heading 1</h4> <h5>Heading 1</h5> <h6>Heading 1</h6> <p>This is peragraph.</p> <p>Horizontal Line Below</p> <hr /> </body> </html> Output Of Above Code... Output

How Add Attributes In HTML

How Add Attributes In HTML

  • The name is the property you want to set. For example, the paragraph <p> element in the example carries an attribute whose name is align, which you can use to indicate the alignment of paragraph.
  • The value is what you want the value of the property to be set and always put within quotations. The below example shows three possible values of align attribute: left, center and right.
  • Attribute names and attribute values are case-insensitive.

    Example

    <html>
     
       <head> 
       <title>Attribute  Example</title> 
       </head>
     <body> 
     <p align = "left">This is left alignement</p> 
     <p align = "center">This is center alignement</p> 
     <p align = "right">This is right alignement</p> 
    </body>
    
    </html>

  • OutPut Screen

    Basic Attributes

    The four Basic attributes that can be used on the majority of HTML are:
    • Id
    • Title
    • Class
    • Style

    Id:

    The id attribute of an HTML tag can be used to uniquely identify any element within an HTML page.
    • If an element carries an id attribute as a unique identifier, it is possible to identify just that element and its content.
    • If you have two elements of the same name within a Web page (or style sheet), you can use the id attribute to distinguish between elements that have the same name.
    Example
    <p id = "html">This para explains what is HTML</p>
    <p id = "css">This para explains what is Cascading Style Sheet</p>
    

    title:

    The title attribute gives a title for the element. They syntax for the title attribute is similar as explained for id attribute:
    Example
    <html>
    
       <head>
          <title>Attribute Example</title>
       </head>
     
       <body bgcolor="#993300">
     <h3 title = "Hello HTML!;"style="font-size:19s;" align="center">Example of Title Attribute in Heading Tag iclude style attributes</h3>
       </body>
     
    </html>
    Image
    Output Screen
    Now try to bring your cursor over "Titled Heading Tag Example" and you will see that whatever title you used in your code is coming out as a tooltip of the cursor.

    The class Attribute

    The class attribute is used to associate an element with a style sheet, and specifies the class of element. 
    The value of the attribute may also be a space-separated list of class names. For example −
    class = "className1 className2 className3"
    

    The style Attribute

    The style attribute allows you to specify Cascading Style Sheet (CSS) rules within element.
    <html>
    
       <head>
          <title>Attribute Example</title>
       </head>
     
       <body bgcolor="#993300">
     <h3 title = "Hello HTML!;"style="font-size:19s;" align="center">Example of Title Attribute in Heading Tag iclude style attributes</h3>
       </body>
     
    </html>
    Image
    Output Screen

    Internationalization Attributes

    There are three internationalization attributes, which are available for most XHTML elements.
    • dir
    • lang
    • xml:lang

    The dir Attribute

    The dir attribute allows you to indicate to the browser about the direction in which the text should flow. The dir attribute can take one of two values, as you can see in the table that follows −
    ValueMeaning
    ltrLeft to right (the default value)
    rtlRight to left (for languages such as Hebrew or Arabic that are read right to left)
    Example
     <html dir = "rtl">
       <head>
          <title>Display Directions</title>
       </head>
     
       <body>
          This is how IE 5 renders right-to-left directed text.
       </body>
     
    </html>
    
    When dir attribute is used within the <html> tag, it determines how text will be presented within the entire document. When used within another tag, it controls the text's direction for just the content of that tag.

    The lang:

    The lang attribute allows you to indicate the main language used in a document, but this attribute was kept in HTML only for backwards compatibility with earlier versions of HTML. This attribute has been replaced by the xml:lang attribute in new XHTML documents.
    The values of the lang attribute are ISO-639 standard two-character language codes. Check HTML Language Codes: ISO 639 for a complete list of language codes.
    Example
    <html lang = "en">
       <head>
          <title>English Language Page</title>
       </head>
    
       <body>
          This page is using English Language
       </body>
    
    </html>
    AttributeOptionsFunction
    alignright, left, centerHorizontally aligns tags
    valigntop, middle, bottomVertically aligns tags within an HTML element.
    bgcolornumeric, hexidecimal, RGB valuesPlaces a background color behind an element
    backgroundURLPlaces a background image behind an element
    idUser DefinedNames an element for use with Cascading Style Sheets.
    classUser DefinedClassifies an element for use with Cascading Style Sheets.
    widthNumeric ValueSpecifies the width of tables, images, or table cells.
    heightNumeric ValueSpecifies the height of tables, images, or table cells.
    titleUser Defined"Pop-up" title of the elements.

Comments

Popular posts from this blog

HTML Character Sets

HTML Declaration

HTML Canvas Tutorial