























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























































Hyper Text Markup Language (HTML)
3.1 Introduction
Hyper Text Markup Language (HTML) is a markup language designed for the creation of web pages with hypertext and other information to be displayed in a web browser. HTML is used to structure the information denoting certain text as headings, paragraphs, lists and so on and can be used to describe the appearance and semantics of a document. An HTML file is a text file containing predefined tags(<..>). The attributes can be set through the HTML tags and it must be written only in the start tag.
HTML was originally defined by Tim Berners-Lee, HTML is now an international standard (ISO/IEC 15445:2000). Later HTML specifications are maintained by the World Wide Web Consortium (W3C). One can write the HTML in a plain text editor, such as Note Pad, or use an HTML editor.The markup tags tell the Web browser how to display the page.An HTML file must have an. htm or. html file extension.
3.2 Basic HTML Document Structure
The structure of HTML is as follows.
Your Page Title
This area will contain everything that will be visible through a web browser, such as text and graphics. All of the information will be HTML coded.
**** - Begins the HTML document. **** - Contains information about the page such as the TITLE, META tags for proper Search Engine indexing, STYLE tags, which determine the page layout, and
JavaScript coding for special effects. **** - The TITLE of the page. This will be visible in the title bar of the viewers’ browser. **** - Closes the tag. It is the end tag of title tag. </HEAD> - Closes the <HEAD> tag.
<BODY> - This is where you will begin writing your document and placing your HTML codes. </BODY> - Closes the <BODY> tag. </HTML> - Closes the <HTML> tag.
3.3 Basic HTML Tags
HTML elements are defined using HTML tags.
HTML Elements
HTML documents are text files made up of HTML elements.
Example
<b>This text is bold</b> The HTML element starts 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
far the glyph for the lowercase "o" extends below the baseline, and subtract that value from the top of its bounding box. In the cases where it is impossible or impractical to determine the x-height, a value of 0.5em should be used.
The rule: h1 { line-height: 1.2em } means that the line height of "h1" elements will be 20% greater than the font size of the "h1" elements. On the other hand: h1 { font-size: 1.2em } means that the font-size of "h1" elements will be 20% greater than the font size inherited by "h1" elements. Pixel units are relative to the resolution of the viewing device, i.e., most often a computer display. It is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel.
In the following rules, the computed 'text-indent'^ value of "h1" elements will be 36px, not 45px, if "h1" is a child of the "body" element.
body { font-size: 12px; text-indent: 3em; /* i.e., 36px */ } h1 { font-size: 15px }
Absolute length units are only useful when the physical properties of the output medium are known. The absolute units are:
h1 { margin: 0.5in } /* inches / h2 { line-height: 3cm } / centimeters / h3 { word-spacing: 4mm } / millimeters / h4 { font-size: 12pt } / points / h4 { font-size: 1pc } / picas */ Percentages The format of a percentage value (denoted by ^ in this specification) is a ^ immediately followed by '%'.
Percentage values are always relative to another value, for example a length. Each property that allows percentages also defines the value to which the percentage refers. The value may be that of another property for the same element, a property for an ancestor element, or a value of the formatting context (e.g., the width of a containing block). When a percentage value is set for a property of the root element and the percentage is defined as referring to the inherited value of some property, the resultant value is the percentage times the initial value of that property.
Since child elements (generally) inherit the computed values of their parent, in the following example, the children of the P element will inherit a value of 12px for 'line- height', not the percentage value (120%):
p { font-size: 10px } p { line-height: 120% } /* 120% of 'font-size' */
3.3.2 Formatting Tags
Header Tags
Headings are defined with the to tags. defines the largest heading. defines the smallest heading. HTML automatically adds an extra blank line before and after a heading.
Example
This is a heading
- The paragraph will be aligned in the right.
Break Tag
The
tag is used when one want to end a line, but don't want to start a new paragraph. The
tag forces a line break wherever it will be needed. The
tag is an empty tag. It has no closing tag.
Example
To break
lines
in a
paragraph,
use the br tag.
Output
To break lines in a paragraph, use the br tag.
Comment Tag
The comment tag is used to insert a comment in the HTML source code. The browser will ignore a comment. One can use comments to explain the code, which can help us when the editing is needed in the source code at a later stage. In this an exclamation point should be included after the opening bracket, but not before the closing bracket.
Example
**Horizontal rule** tag is used to draw a horizontal line. **Table 3.2 Attributes of Hr tag**Attribute Value Description
align left center right
Use styles instead. Specifies the alignment of a hr element
noshade noshade Use styles instead. Specifies that a hr element should render in one solid color (noshaded), instead of a shaded color size pixels Use styles instead. Specifies the height of a hr element width pixels %
Use styles instead. Specifies the width of a hr element Example
The hr tag defines a horizontal rule:
This is a paragraph
This is a paragraph
This is a paragraph
This is a paragraph
Output The hr tag defines a horizontal rule:
Defines teletype text
Defines a variable
Defines preformatted text
Table 3.5 Citations, Quotations, and Definition Tags
Tag Description
Defines an abbreviation
Defines an acronym
Defines an address element
Defines the text direction
Defines a long quotation
Defines a short quotation
Defines a citation
Defines a definition term
Example ** This text is bold
This text is strong
This text is big **
This text is emphasized
This text is italic
This text is small
This text contains
subscript
This text contains
superscript
Output
This is preformatted text. It preserves both spaces and line breaks. The pre tag is good for displaying computer code: for i = 1 to 10 print i next i
Address Tag
It demonstrates how to write an address in an HTML document.
Example
Donald Duck
BOX 555
Disneyland
USA
The Output is
Donald Duck BOX 555
Disneyland USA Font Tag The tag is used to give the size, color etc of font. It is deprecated. It is supposed to be removed in a future version of HTML. Example
This is a paragraph.
This is another paragraph.
Output: This is a paragraph. This is another paragraph. **Table 3.6 Attributes of Font Tag**Attribute Example Purpose
size="number" size="2" Defines the font size
size="+number" size="+1" Increases the font size
size="-number" size="-1" Decreases the font size
face="face-name" face="Times" Defines the font-name
color="color-value" color="#eeff00" Defines the font color
color="color-name" color="red" Defines the font color
This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it.
** tag**
The tag in HTML is a tag that defines logical divisions within the content of a page. It means is that a tag defines sections of a Web page to make it easier to manage, style, and manipulate. You can use the tag when you want to center a block of content or position a content block on the page. The tag is a very powerful tool for Web developers.
The tag is a block-level element. The tag can contain nearly any other tag. The tag cannot be inside
tags. The
tag gives you the ability to name certain sections of your documents so that you can affect them with style sheets or Dynamic HTML. It breaks paragraphs. It acts as a paragraph end/beginning, and while you can have paragraphs within a you can't have a inside a paragraph. Example This is a headerThis is a paragraph.
This is a header This is a paragraph The tag supports the following standard attributes: Table 3.7 Attributes of div Tag
Attribute Value Description
class classname Specifies a classname for an element
dir rtl ltr
Specifies the text direction for the content in an element id id Specifies a unique id for an element
lang language_code Specifies a language code for the content in an element style style_definition Specifies an inline style for an element
title text Specifies extra information about an element
xml:lang language_code Specifies a language code for the content in an element, in XHTML documents ** tag** The tag is a tag that groupings of inline content within the content of a page. This means that, a tag defines portions of Web elements to make them easier to manage, style, and manipulate. You can use the tag when you want to change the color of a single word. The tag is a very powerful tool for Web developers because it is so open-ended. The span tag can do anything you want it to do. The tag is an inline-level element. The tag can only contain other inline elements like abbr, strong, or tt. The tag can be inside
tags or
tags. The tag has very similar properties to the tag, in that it changes the style of the text it encloses. But without any style attributes, the tag won't change the enclosed items at all. The primary difference between the and tags is that doesn't do any formatting of it's own. The tag acts includes a paragraph break, because it is defining a logical division in the document. The tag simply tells the browser to apply the style rules to whatever is within the .Use when you want to change the style of elements without placing them in a new block-level element in the document. For example, if you had a Level 3 Heading () that you wanted the second word to be red, you could surround that word with span.
Example: National Engineering College
9 of them. To add spaces to our text, use the character entity. The most common entities are given in the table below.
Table 3.8 Character Entities Result Description Entity Name Entity Number non-breaking space
< less than < < > greater than > > & ampersand & & " quotation mark " " ' apostrophe ' (does not work in IE) ' Result Description Entity Name Entity Number ¢ cent ¢ ¢ £ pound £ £ ¥ yen ¥ ¥ § section § § © copyright © © ® registered trademark ® ® × multiplication × × ÷ division ÷ &#
3.4 HTML Images
HTML images are defined with the tag. Example
GIF & JPG
Computers store images in several different ways. Some storage methods focus on compressing the size of the image as much as possible. A major problem with using images on websites is that images take much longer to load than text. To reduce
download times as much as possible two of the best image compressing formats used on the web is:
Table 3.9 Difference between GIF and JPG
GIF JPG
256 colors Unlimited colors
Can handle transparent areas Can't handle transparent areas
This format is not good at compressing photographs
Excellent for compressing photographs and complex images In general, it is excellent for banners, buttons and clipart
In general, it is not good for banners, buttons and clipart.
This means that:
Image Resizing
You can change the size of an image using the width and height attributes. In general, it is not advisable to reduce image size using these settings, since the image will be transferred over the internet in its original size no matter what reduction is set for it. This will slow the loading of your webpage. This means, that if you have an image that is bigger in size than you want it to be on your page, you should reduce the size in a graphics program, rather than reducing the size on the webpage using the width and height attributes. On the contrary, sometimes, it can be wise to enlarge images using this technique. Below are two presentations of the exact same image - with different settings for width and height.