Skip to main content

HTML Tags

HTML Tags 


What are HTML tags?  
  • ƒ  HTML tags are used to mark-up HTML elements 
  • ƒ  HTML tags are surrounded by the two characters < and > 
  • ƒ  The surrounding characters are called angle brackets 
  • ƒ  HTML tags normally come in pairs like <b> and </b> 
  • ƒ  The first tag in a pair is the start tag, the second tag is the end tag 
  • ƒ  The text between the start and end tags is the element content 
  • ƒ  HTML tags are not case sensitive, <b> means the same as <B> 

Logical vs. Physical Tags  


     In HTML there are both logical tags and physical tags. Logical tags are designed to describe (to the 
browser) the enclosed text's meaning. An example of a logical tag is the <strong> </strong> tag. By 
placing text in between these tags you are telling the browser that the text has some greater 
importance. By default all browsers make the text appear bold when in between the <strong> and 
</strong> tags. 

Physical tags on the other hand provide specific instructions on how to display the text they enclose.
Examples of physical tags include:

  • ƒ  <b>: Makes the text bold.  
  • ƒ  <big>: Makes the text usually one size bigger than what's around it.  
  • ƒ  <i>: Makes text italic.
Physical tags were invented to add style to HTML pages because style sheets were not around, though 
the original intention of HTML was to not have physical tags. Rather than use physical tags to style 
your HTML pages, you should use style sheets.


HTML Elements 
Remember the HTML example from the previous page:

<html>  
<head>  
<title>My First Webpage</title>  
</head>  
<body>  
This is my first homepage. <b>This text is bold</b>  
</body>  
</html> 

This is an HTML element: 

<b>This text is bold</b>

The HTML element begins with a start tag: <b>
The content of the HTML element is: This text is bold
The HTML element ends with an end tag: </b>

The purpose of the <b> tag is to define an HTML element that should be displayed as bold.

This is also an HTML element: 

<body>
This is my first homepage. <b>This text is bold</b>
</body>

This HTML element starts with the start tag <body>, and ends with the end tag </body>. The purpose
of the <body> tag is to define the HTML element that contains the body of the HTML document.


Nested Tags

You may have noticed in the example above, the <body> tag also contains other tags, like the <b> tab.
When you enclose an element in with multiple tags, the last tag opened should be the first tag closed.
For example:

<p><b><em>This is NOT the proper way to close nested tags.</p></em></b>

<p><b><em>This is the proper way to close nested tags. </em></b></p>


Why Use Lowercase Tags? 
You may notice we've used lowercase tags even though I said that HTML tags are not case sensitive.
<B> means the same as <b>. The World Wide Web Consortium (W3C), the group responsible for
developing web standards, recommends lowercase tags in their HTML 4 recommendation, and XHTML
(the next generation HTML) requires lowercase tags.

Tag Attributes 
Tags can have attributes. Attributes can provide additional information about the HTML elements on
your page. The <tag> tells the browser to do something, while the attribute tells the browser how to
do it. For instance, if we add the bgcolor attribute, we can tell the browser that the background color
of your page should be blue, like this: <body bgcolor="blue">.


This tag defines an HTML table: <table>. With an added border attribute, you can tell the browser that
the table should have no borders: <table border="0">. Attributes always come in name/value pairs
like this: name="value". Attributes are always added to the start tag of an HTML element and the
value is surrounded by quotes.

Quote Styles, "red" or 'red'?
Attribute values should always be enclosed in quotes. Double style quotes are the most common, but
single style quotes are also allowed. In some rare situations, like when the attribute value itself
contains quotes, it is necessary to use single quotes:

name='George "machine Gun" Kelly'
For a complete list of tags, visit W3C.org.



Basic HTML Tags 


The most important tags in HTML are tags that  define headings, paragraphs and line breaks.

Basic HTML Tags

Tag Description
<html> Defines an HTML document
<body> Defines the document's body
<h1> to <h6> Defines header 1 to header 6
<p> Defines a paragraph
<br> Inserts a single line break
<hr> Defines a horizontal rule
<!--> Defines a comment

Headings
Headings are defined with the <h1> to  <h6> tags. <h1> defines the largest heading while <h6> defines
the smallest.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>

<h5>This is a heading</h5>
<h6> This is a heading</h6>

HTML automatically adds an extra blank line before and after a headin g. A useful heading attribute is
align.



<h5 align="left">I can align headings </h5>

<h5 align="center">This is a centered heading </h5>

<h5 align="right" >This is a heading aligned to the right </h5>


Paragraphs 


Paragraphs are defined with the <p>  tag. Think of a paragraph as a bl ock of text. You can use the align
attribute with a paragraph tag as well.

<p  align="left">This is a paragraph</p>

<p  align="center">this is another paragraph</p>


Important: You must indicate paragraphs with <p>  elements. A browser ignores any 
indentations or blank lines in the source text. Without  <p>  elements, the document becomes 
one large paragraph. HTML automatically adds an extra blank line before and after a paragraph. 

Line Breaks 


The <br> tag is used when you want to start a new line,  but don't want to start a new paragraph. The
<br> tag forces a line break wherever you place it. It is similar to single spacing in a document.

This Code    Would Display
<p>This <br> is a para<br> graph with
line breaks</p>
This
is a para
graph with line breaks

The <br> tag has no closing tag.

Horizontal Rule
The <hr> element is used for horizontal rules that  act as dividers between sections, like this:


The horizontal rule does not have a closing tag. It takes attributes such as align and width. For
instance:

This Code  Would Display
<hr width="50%" align="center">


Comments in HTML  


The comment tag is used to insert a comment in  the HTML source code. A comment can be placed
anywhere in the document and the browser will ignore everything inside the brackets. You can use
comments to write notes to yourself, or write a helpful message to someone  looking at your source
code.


Notice you don't see the text between the tags  <!-- and  --> . If you look at the source code, you
would see the comment. To view the source code for this page, in your browser window, select View
and then select Source .

Note: You need an exclamation po int after the opening bracket  <!-- but not before the closing 
bracket --> . 


HTML automatically adds an extra blank line before and after some  elements, like before and after a
paragraph, and before and after a heading. If you wa nt to insert blank lines into your document, use
the  <br> tag.

This Code Would Display
<p> This html comment would  <!-- This  This HTML comment would be displayed like this.

Try It Out!
Open your text editor and type the following text:

<html> 
<head> 
<title>My First Webpage</title> 
</head> 
<body> 
<h1 align="center">My First Webpage</h1> 
<p>Welcome to my first web page. I am writing this page using a text editor and plain 
old html.</p> 
<p>By learning html, I'll be able to create web pages like a pro....<br> 
which I am of course.</p>  
</body> 
</html> 

Save the page as mypage2.html. Open the file in your Internet browser. To view how the page
should look, visit this web page:  http://profdevtrain.austincc.edu/html/mypage2.html
for more html details click here

Comments

Popular posts from this blog

PHP INTRODUCTION

                     PHP  (recursive acronym for  PHP: Hypertext Preprocessor ) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. PHP stands for  P HP:  H ypertext  P reprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) PHP is an open source software PHP is free to download and use Why PHP? PHP runs on different platforms (Windows, Linux, Unix, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP is FREE to download from the official PHP resource:  www.php.net PHP is easy to learn and runs efficiently on the server side What can PHP do? Anything. PHP is mainly focused on server-side scripting, so you can...

MySQL General Architecture

        MySQL operates in a networked environment using a client/server architecture. In other words, a central  program acts as a server, and various client programs connect to the server to make requests. A MySQL  installation has the following major components: MySQL Server, Client programs and MySQL non client  utilities.  MySQL Server MySQL Server, or mysqld, is the database server program. The server manages access to the actual  database (schema) on disk and in memory. MySQL Server is multi-threaded and supports many  simultaneous client connections. Clients can connect via several connection protocols. For managing  database contents, the MySQL server features a modular architecture that supports multiple storage engines  that handle different types of tables (for example, it supports both transactional and non-transactional  tables). Keep in mind the difference between a server and a host. The server is s...

MySQL Query Browser

     MySQL Query Browser is a cross-platform GUI client program that's intuitive and easy to use. It provides a graphical interface to the MySQL server for querying and analyzing data. The MySQL Query Browser provides a Connection dialog that enables a connection to a MySQL server. This section describes how to use the Connection dialog and the Main Query Browser GUI. Using the Connection Dialog MySQL Query Browser presents a Connection dialog when it starts or when the New Instance Connection … is selected from the File menu. Connecting to a MySQL server can be accomplished either by filling in the connection dialog box fields with the parameters required to connect to a server or selecting from among any predefined connection profiles. Connection Dialog Window:                To connect to a MySQL server by specifying connection parameters directly, fill in the  appropriate fields beginning with the ...