Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
What is HTML?
• means HyperText Markup Language
• it is based on Structured Generalized
Markup Language- SGML
• uses tags and texts
• HTML is interpreted by a browser
• it does not define precise layout (browsers
decide how the display HTML)
HTML Source- 1
• consists of ASCII text
• Use a simple text editor for learning HTML
(e.g. Microsoft Notepad)
• HTML editors automates the process
• Latest Office products produce HTML
directly
• File endings are .htm or .html
HTML Source - 2
• Start tag switches format on < >
• End tag switches format off </>
• For example, <I> text </I>
- this switches italics on and off
Tag Syntax
• Tag names are not case sensitive (but use
uppercase!)
• Cannot have spaces after <
- <I> not < I>
• Can have spaces and other text before >
• Start tags can have attributes
- <tag_name attribute name>
- <tag_name attribute name=“argument”>
• Tags can be intermixed with text
MAIN TAGS IN HTML
• <HTML> and </HTML> - used to delimit an
HTML document (the start tag informs the browser
that an HTML document follows)
• <HEAD> AND </HEAD> - marks off
information about the whole document
• <BODY> AND </BODY> - defines the body or
text of a page (all that is intended to be read goes
here)
• <TITLE> AND </TITLE> - denotes the title of the
web page
General Web Page Structure
<HTML>
<HEAD>
<TITLE> title text goes here </TITLE>
</HEAD>
<BODY>
The text of the page goes here
</BODY>
</HTML>
Example 1
<HTML>
<HEAD>
<TITLE> My Web Page </TITLE>
</HEAD>
<BODY>
This is <I>my</I> first web page
</BODY>
</HTML>
Types of Tags
• Relative Tags:
browser can interpret meaning
• Fixed Tags:
- browser must supply the exact formatting
- these include those formatting types that
are possible even on a simple text terminal
Fixed Tags
• <I> </I> - applies an italic format
• <U> </U> - makes the browser
underline the text
• <B> </B> - makes the text appear
bold
Example 2
<HTML>
<HEAD>
<TITLE> My Web Page </TITLE>
</HEAD>
<BODY>
This is <I>my</I> first web page
The next two words <B>are bold</B>
<U>This text is underlined </U>
Now back to unformatted text
</BODY>
</HTML>
Controlling Line Spacing
• Browsers do not recognize source line
layout
• Use explicit line spacing tags:
<BR> and </BR>
- causes a line break in output
- can use just <BR>
• <P> and </P> : causes a paragraph format
Example 3
<HTML>
<HEAD>
<TITLE> My Web Page </TITLE>
</HEAD>
<BODY>
<P>This is <I>my</I> first web page</P>
The next two words <B>are bold</B><BR>
<U>This text is underlined </U><BR>
Now back to unformatted text
</BODY>
</HTML>
Headings
• <H1> </H1> The most prominent heading
• <H2> </H2>
• <H3> </H3>
• <H4> </H4>
• <H5> </H5>
• <H6> </H6> The least prominent heading
• All heading types add a line break after
end tag
Example 4
<HTML>
<HEAD>
<TITLE> My Web Page </TITLE>
</HEAD>
<BODY>
<H1> Example HTML Source </H1>
<P>This is <I>my</I> first web page</P>
The next two words <B>are bold</B><BR>
<U>This text is underlined </U><BR>
Now back to unformatted text
</BODY>
</HTML>
More relative Style Tags
• <STRIKE> - adds strike out
• <BIG> and </BIG> - puts text in a big font
• <SMALL> and </SMALL> - puts text in a
small font
• <SUB> and </SUB>- use subscripts
• <SUP> and </SUP>- use superscripts
Example 5
<HTML>
<HEAD>
<TITLE> My Web Page </TITLE>
</HEAD>
<BODY>
<H1> Example HTML Source </H1>
<P>This is <I>my</I> first web page</P>
The next two words <B>are bold</B><BR>
<U>This text is underlined </U><BR>
Now back to unformatted text
<EM>emphasis<STRONG>emphasis and strong
<STRIKE>emphasis, strong and strikeout
</STRIKE></STRONG></EM>
</BODY>
</HTML>
RULES
• <HR>- draws a horizontal line across the page
• <HR WIDTH=“width”> - defines the width of the
rule
• WIDTH=“250” - as width in pixels
• WIDTH=“75%” - as width as a percentage
• <HR ALIGN=“alignment” WIDTH=“width”>
- alignment (left, center or right) and width
Example 6
<HTML>
<HEAD>
<TITLE> My Web Page </TITLE>
</HEAD>
<BODY>
<H1> Example HTML Source </H1>
<HR ALIGN=left WIDTH =“75%”>
<P>This is <I>my</I> first web page</P>
The next two words <B>are bold</B><BR>
<U>This text is underlined </U><BR>
Now back to unformatted text
<EM>emphasis<STRONG>emphasis and strong
<STRIKE>emphasis, strong and strikeout
</STRIKE></STRONG></EM>
</BODY>
</HTML>
Comments
• <!--This is a comment-->