150 likes | 304 Views
HTML Introduction (cont.). First Example. <html> <head> <TITLE> A Simple HTML Example </TITLE> </head> <body> <H1>Welcome to Math 279</H1> <P>Math 279 is fun! This is the first paragraph.</P> <P>And this is the second paragraph.</P> </body> </html>.
E N D
HTML Introduction (cont.) Lecture 6, MAT 279, Fall 2009
First Example <html> <head> <TITLE>A Simple HTML Example</TITLE> </head> <body> <H1>Welcome to Math 279</H1> <P>Math 279 is fun! This is the first paragraph.</P> <P>And this is the second paragraph.</P> </body> </html> Lecture 6, MAT 279, Fall 2009
For my information only, I do not want to display this in the webpage First Example <html> <head> <TITLE>A Simple HTML Example</TITLE> </head> <body> <H1>Welcome to Math 279</H1> <P>Math 279 is fun! This is the first paragraph.</P> <P>And this is the second paragraph.</P> <P>HTML structure must have head and body tags.</P> </body> </html> Lecture 6, MAT 279, Fall 2009
How to comment • <!--, …, -->, comment tag • <!-- anything inside a comment tag is ignored by the web browsers --> • Important for documenting your html files Lecture 6, MAT 279, Fall 2009
How about making lists in the page? I want to create a small HTML tutorial, e.g., HTML has many Tags: • HTML tags • Head tags • Title tags • Body tags Lecture 6, MAT 279, Fall 2009
Adding lists • unordered list (bulleted list): <ul> … </ul> • ordered list (enumerated list): <ol> … </ol>: • <li>…</li>: specify each list item for both unordered and ordered lists • definition list: <dl>…</dl> • a list of definitions • <dt>…</dt>: definition term • <dd>…</dd>: definition description Lecture 6, MAT 279, Fall 2009
Example for list tags <html> <head> <TITLE>Example for list tags</TITLE> </head> <body> Three kinds of tags are <ul> <li>HTML tags</li> <li>Head tags</li> <li>Body Tags</li> </ul> <ol> <li>HTML tags</li> <li>Head tags</li> <li>Body Tags</li> </ol> <dl> <dt>HTML tags:</dt> <dd>support begin and end of html document</dd> <dt>Head tags:</dt> <dd>support header information</dd> <dt>Body tags:</dt> <dd>support main information in the webpage</dd> </dl> </body> </html> Lecture 6, MAT 279, Fall 2009
Back to First Example You want to make the text bold <html> <head> <TITLE>A Simple HTML Example</TITLE> </head> <body> <H1>Welcome to Math 279</H1> <P>Math 279 is fun! This is the first paragraph.</P> <P>And this is the second paragraph.</P> </body> </html> Lecture 6, MAT 279, Fall 2009
Working with inline elements • <b>,…,</b>: boldface element, darkens any text inside • How about italicize? • <i>,…,</i>: italicizes any text inside • Inline element: marks a section of text within a block-level element Lecture 6, MAT 279, Fall 2009
Quick review • Four basic HTML tags… • Block-level elements • contain content viewed as distinct block within webpage • when rendered visually, start on a new line • example? • In-line elements • marks a section of text within a block-level element • example? Lecture 6, MAT 279, Fall 2009
What if I decide to change the style of the text inside the Tags? Lecture 6, MAT 279, Fall 2009
Attributes in Tags Lecture 6, MAT 279, Fall 2009
Attributes in tags • a property of an HTML element (tag) • consists of • attribute_name and • attribute_value • used with opening tag • Example: ALIGN attribute • attribute_name: ALIGN • atribute_value: LEFT | CENTER | RIGHT • <H1>Welcome to MAT 279</H1> • <H1 ALIGN = “CENTER”>Welcome to MAT 279</H1> Lecture 6, MAT 279, Fall 2009
The style attribute • controls how the browser displays an element • used with opening tag • syntax <elementstyle=“rules” … > content </element> • rules • a set of style rules • entered by specifying a style name followed by a colon and then a style value style=“name1:value1; name2:value2; …” • e.g. <h1 style=“text-align:center”>Welcome to MAT 279</h1> <h1 style=“color: blue”>Welcome to MAT 279</h1> <h1 style=“text-align:center; color:blue”>Welcome to MAT 279</h1> Lecture 6, MAT 279, Fall 2009
Empty element – single Tag • an empty element contains no contents • usually one-side elements • e.g. • line break: <br /> • horizontal line: <hr /> • exercise • add line breaks between two sentences in a paragraph. • add horizontal lines after each list. Lecture 6, MAT 279, Fall 2009