HTML - Basic Tags

 
Line Breaks
 
Whenever line break is needed <BR> tag is used. <BR> tells your browser to go to the beginning of the next line. <BR> acts in the same way as the ENTER key on your keyboard. When you press the ENTER key, the cursor goes to the beginning of the next line. This element does not have any attributes. It is an empty tag.
 
Preventing Line Breaks
 
The opposite of creating a line break is preventing a line break. Sometimes you want a string of words to appear all on the same line. For eg. March 1788. Many a times, March and 1788 to appear on the same the end of one line and 1788 appearing at the beginning of the next line by inserting a nonbreaking space between March and 1788. The nonbreaking space is an entity and not a printable character. To insert a nonbreaking space, you can use either the character representation of &nbsp; or the decimal representation of &#160.
 
Paragraph
 
Paragraphs are defined with <P> and </P> tag. HTML automatically adds an extra blank line before and after a paragraph. Paragraph can be aligned according to the user requirement. For aligning a paragraph, align keyword is used. Possible values are left, right, center and justify. Left is the default alignment. It is a non empty tag.
 
Pre Formatted Text
 
Tells the browser the enclosed text is preformatted and should not be reformatted. It is a non-empty tag.
 
Horizontal Rule
 
Horizontal Rule tag is used to draw horizontal line on the web page. <HR> is used for drawing a horizontal rule. It is an empty tag. To customize the horizontal rule four attributes are provided all of which are optional. Various attributes are as follows:
size: This attribute specifies the height of the horizontal line. It takes integer value. Line becomes thicker as the value increases and thinner as the value decreases.
 
width: This attribute specifies the length of the horizontal line. If this attribute is not specified the line will be drawn in the full window from left to right. The value can be specified as an integer value or percentage. If the value is given as a percentage then the line will be drawn as the specified percentage of the window.
 
align: This attribute specifies the alignment of the horizontal line. Default alignment is left. Possible values are left, right and center. 
 
noshade: When set to true the rule should render in a solid color, when set to false the rule should render in a two-color. This means that no shading is desired when the horizontal line is rendered.
 
color: This attribute gives the color to the horizontal rule.
 
src: An image can be applied to the horizontal rule with the help of this attribute. Specify the path of the image to be filled in the horizontal rule.
 
Division
 
Selects a block of text so that you can apply styles. <DIV> and </DIV> tags are used for making a block i.e. it defines logical divisions in your web page. It acts a lot like a paragraph tag, but it divides the page up into larger sections. The <DIV> tag is useful for applying alignment and style characteristics to a section of a document that contains multiple elements rather than having to apply the alignment and styles to each element in the block. Each <DIV> element starts on a new line and leaves a blank line before and after every <DIV> tag. <DIV> also gives you the chance to define the style of whole sections of HTML. The <DIV> tag gives you the ability to name certain sections of your documents so that you can affect them with style sheets or Dynamic HTML. <DIV> tag is that it breaks paragraphs. It acts as a paragraph end/beginning, and while you can have paragraphs within a <DIV> you can't have a <DIV> inside a paragraph. It is a non-empty tag. Various attributes are as follows:
 
align: This attribute sets the horizontal alignment of the block of content. Possible values are left (default), right, center and justify.
 
class: It specifies the style class to be used by the element. The styles are defined by the <STYLE> tag in the header of the document or in a separate style sheet file.
 
id: It specifies the unique alphanumeric value for the tag which is used for reference.
 
style: This attribute specifies a particular style for a specific element.
 
Span
 
If you only want to apply styles to a few words or letters, you use the SPAN element. You can think of the SPAN element as spanning a few words or characters. The <SPAN> tag is used to group inline-elements in a document. This means that user can apply styles to a block of elements.
 
The <DIV> element functions as a “block” level element. Block level elements (<P>, <H#>, and <HR> for instance) all mark off divisions in a page’s structure. As such, generally they add blank lines before and after their content. On the other hand, <SPAN> is not a block level element. It functions as an inline generic container that you can use to insert almost anything into a page.