The document provides an overview of HTML elements for formatting text, images, links, lists, tables and more. It defines common HTML tags like <head>, <body>, <p>, <h1>-<h6>, <img>, <a>, <ul>, <ol>, <table>, <tr>, and <td> and describes their attributes and usage. The document is intended as a tutorial for basic HTML markup.
2. Definitions WWW -- a software infrastructure layered on top of the Internet HTTP -- HyperText Transport Protocol, layered on top of TCP HTTPS -- secure HTTP using encryption HTML -- HyperText Markup Language, version 4.01 is current
3. HTML Page Format <HTML> <HEAD> <TITLE> Qi’s web! </TITLE> </HEAD> <BODY> <H1> Hello World </H1> <! Rest of page goes here. This is a comment. > </BODY> </HTML>
4. BODY Element <BODY attributename="attributevalue"> Deprecated attributes (but still used) BACKGROUND=“ Sunset.jpg” (can be tiled) BGCOLOR=color TEXT= color LINK= color (unvisited links) VLINK= color (visited links) ALINK= color (when selected)
5. Headings <H1 ...> text </H1> -- largest of the six <H2 ...> text </H2> <H3 ...> text </H3> <H4 ...> text </H4> <H5 ...> text </H5> <H6 ...> text </H6> -- smallest of the six ALIGN= "position" --left (default), center or right
7. <P> Paragraph <P> defines a paragraph Add ALIGN= "position" (left, center, right) Multiple <P>'s do not create blank lines Use <BR> for blank line Fully-specified text uses <P> and </P> But </P> is optional
8. <BODY> <P>Here is some text </P> <P ALIGN="center"> Centered text </P> <P><P><P> <P ALIGN="right"> Right-justified text <! Note: no closing /P tag is not a problem> </BODY>
9. <PRE> Preformatted Text <PRE> if (a < b) { a++; b = c * d; } else { a--; b = (b-1)/2; } </PRE>
11. Colors Values for BGCOLOR and COLOR many are predefined (red, blue, green, ...) all colors can be specified as a six character hexadecimal value: RRGGBB FF0000 – red 888888 – gray 004400 – dark green FFFF00 – yellow
12. Fonts <FONT COLOR="red" SIZE="2" FACE="Times Roman"> This is the text of line one </FONT> <FONT COLOR="green" SIZE="4" FACE="Arial"> Line two contains this text </FONT> <FONT COLOR="blue" SIZE="6" FACE="Courier" The third line has this additional text </FONT> Note: <FONT> is now deprecated in favor of CSS.
13. Ordered (Numbered) Lists <OL TYPE="1"> <LI> Item one </LI> <LI> Item two </LI> <OL TYPE="I" > <LI> Sublist item one </LI> <LI> Sublist item two </LI> <OL TYPE="i"> <LI> Sub-sublist item one </LI> <LI> Sub-sublist item two </LI> </OL> </OL> </OL>
14. Unordered (Bulleted) Lists <UL TYPE="disc"> <LI> One </LI> <LI> Two </LI> <UL TYPE="circle"> <LI> Three </LI> <LI> Four </LI> <UL TYPE="square"> <LI> Five </LI> <LI> Six </LI> </UL> </UL> </UL>
16. Logical Character Styles <H1>Logical Character Styles</H1> <EM>Emphasized</EM><BR> <STRONG>Strongly Emphasized</STRONG><BR> <CODE>Code</CODE><BR> <SAMP>Sample Output</SAMP><BR> <KBD>Keyboard Text</KBD><BR> <DFN>Definition</DFN><BR> <VAR>Variable</VAR><BR> <CITE>Citation</CITE><BR> <EM><CODE>Emphasized Code</CODE></EM><BR> <FONT COLOR="GRAY"><CITE>Gray Citation</CITE></FONT><BR> <ACRONYM TITLE="Java Development Kit">JDK Acronym</ACRONYM>
17. <A> Anchors (HyperLinks) Link to an absolute URL: If you get spam, contact <A HREF="htttp:www.microsoft.com"> Microsoft </A> to report the problem. Link to a relative URL: See these <A HREF="#references"> references </A> concerning our fine products. Link to a section within a URL: Amazon provided a <A HREF="www.amazon.com/#reference"> reference for our company. </A>
18. Naming a Section <H2> <A NAME="#references"> Our References </A> </H2> Example
19. Hyperlinks <BODY> <H3>Welcome to <A HREF="http://www.cs.virginia.edu"> <STRONG>Computer Science</STRONG></A> at the <A HREF="www.virginia.edu">University of Virginia.</A> </H3> </BODY>
20. Images SRC is required WIDTH, HEIGHT may be in units of pixels or percentage of page or frame WIDTH="357" HEIGHT="50%" Images scale to fit the space allowed
21. Images Words align with middle of image Middle Image is left; words align with bottom of image Bottom Image is left; words align with top of image Top Image on right edge; text flows to left Right Image on left edge; text flows to right of image Left Image/Text Placement Align= position
22. Images <BODY> <img src="dolphin.jpg" align="left" width="150" height="150" alt="dolphin jump!"> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> This is a very cute dolphin on the left!<br> You can see text wrap around it<br> </BODY> </HTML>
28. <TABLE> Element Attributes ALIGN= position -- left, center, right for table BORDER= number -- width in pixels of border (including any cell spacing, default 0) CELLSPACING= number -- spacing in pixels between cells, default about 3 CELLPADDING= number -- space in pixels between cell border and table element, default about 1 WIDTH= number[%] -- width in pixels or percentage of page/frame width
30. <TABLE> Element Attributes BGCOLOR= color -- background color of table, also valid for <TR>, <TH>, and <TD> RULES= value -- which internal lines are shown; values are none, rows, cols, and all (default) EX: <TABLE COLS=“40%, *,*”> <TABLE ROWS=“*,*”>
31. <TR> Table Row Attributes Valid for the table row: ALIGN -- left, center, right VALIGN -- top, middle, bottom BGCOLOR -- background color <TABLE ALIGN="center" WIDTH="300" HEIGHT="200"> <TR ALIGN="left" VALIGN="top" BGCOLOR="red"><TD>One</TD><TD>Two</TD> <TR ALIGN="center" VALIGN="middle" BGCOLOR="lightblue"><TD>Three</TD><TD>Four</TD> <TR ALIGN="right" VALIGN="bottom" BGCOLOR="yellow"><TD>Five</TD><TD>Six</TD> </TABLE>
32. <TD> Table Cell Attributes Valid for the table cell: colspan -- how many columns this cell occupies rowspan – how many rows this cell occupies <TABLE ALIGN="center" WIDTH="300" HEIGHT="200" border="1"> <TR> <TD colspan="1" rowspan="2">a</TD> <TD colspan="1" rowspan="1">b</TD> </TR> <TR> <TD colspan="1" rowspan="1">c</TD> </TR> </TABLE>
33. Frames Frames help control navigation and display <FRAME> attributes include FRAMEBORDER – yes or 1 for borders FRAMESPACING – width of border BORDERCOLOR – color SRC – location of HTML to display in frame NAME – destination for TARGET attribute
34. Frames MARGINWIDTH – left/right margins MARGINHEIGHT – top/bottom margins SCROLLING – yes or 1 adds scroll bar NORESIZE – yes or 1 disables resizing
38. Cascading Style Sheets A powerful way to specify styles and formatting across all documents in a web site Style sheets can be specified inline or as a separate document Helps to keep a common look and feel
39. CSS General form: selector {property: value} or selector {property1: value1; property2: value2; ... propertyn: valuen }
40. CSS H1 {text-align: center; color: blue; font: Arial, Times New Roman} P {text-align: left; color: red; font-family: Tahoma, Arial Narrow; font-style: italics}