1 / 45

Creating basic HTML web pages

Creating basic HTML web pages. R. Chris Fraley | http://www.web-research-design.net/P593/. HTML web pages. Most web pages are written in a language called HTML (hypertext markup language).

norris
Télécharger la présentation

Creating basic HTML web pages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Creating basic HTML web pages R. Chris Fraley | http://www.web-research-design.net/P593/

  2. HTML web pages • Most web pages are written in a language called HTML (hypertext markup language). • HTML files exist on a web server. When a person types in the URL for a specific file in his or her web browser, the person is essentially retrieving that pre-existing file from the web server.

  3. HTML • There are many programs that are designed to help you create HTML files • Macromedia’s Dreamweaver • Microsoft’s FrontPage • These kinds of programs are often called WYSIWYG programs. They allow you to create web pages in the way in which you want them to appear; the HTML code is generated in the background.

  4. WYSIWYG • There are two reasons for NOT using these kinds of programs if you’re going to be conducting research over the Internet. • Not dynamic. We’ll be writing CGI scripts that create the code on-the-fly (i.e., web programs that create web pages). As such, a WYSIWYG program cannot help us. • Code bloat. These programs often create unnecessary and confusing code if you revise your pages or make changes.

  5. EditPlus • Although there are good reasons not to use WYSIWYG programs, there are good reasons to use programs that will make HTML coding easier for you. • The perks of EditPlus (http://www.editplus.com/) • Free trial version • Works in a lot like MS Word (e.g., buttons for placing text in bold), but creates the HTML code for you rather than doing so in the background. • Built-in browser so you can see what your code looks like as you write it • Color-coding • Spell checking

  6. Let’s begin . . .

  7. [Live examples of creating HTML code using EditPlus. Review use of text, basic formatting (bold, italics), line breaks, colors. Inserting images, links, and sound files. Using CSS to format things in a global fashion.]

  8. HTML Tags HTML web pages are based on a combination of text and tags. Tags are programming commands used to modify the contents of a web page. They are used, for example, to change the color of the text, the size of the text, insert images, etc. Example: <B> and </B> Most (but not all) tags have an “opening” and “closing” tag. The opening tag is used to tell the browser that a new command is coming and the closing tag tells the browser that the command is complete.

  9. HTML Tags The most basic tag is the HTML tag. This is used so the browser will know that the content to follow is HTML code/content. (Most browsers assume this by default even without the use of the HTML tag.) <HTML> </HTML>

  10. HTML Tags Any text that is placed in-between these tags will be rendered by the browser. Try this example. <HTML> The purpose of this experiment is to learn more about the way people understand others. </HTML>

  11. HTML Tags - Bold Text can be formatted in ways that you would normally do so in a program like MS Word. To set something in bold, use the <B> </B> tags and include the piece to be set in bold in-between. Try this example. <HTML> The purpose of this experiment is to learn more about the way <B>people</B> understand <B>machines</B>. </HTML>

  12. HTML Tags - Italics Italics work in the same way. The HTML tags for setting text in italics is <I> and </I> Try this example. <HTML> Although the average score in this sample is 4.23, <I>your score</I> was 6.32. </HTML>

  13. Font size and color To set the font face, use the <FONT> </FONT> tags. Note: The font tag is the first of several tags we will discuss that have attributes. For example, when setting the font, you can adjust the face, the size, and the color. The examples will make this clear. <HTML> <FONT SIZE=2 FACE=arial COLOR=blue> Welcome to our lab web page! </FONT> </HTML>

  14. Font size and color Another example. <HTML> <FONT SIZE=3 FACE=arial COLOR=blue> Personality Research Lab </FONT> <FONT SIZE=2 FACE=arial COLOR=blue> Welcome to our lab web page! </FONT> </HTML>

  15. Line spacing In HTML, carriage returns are not coded as line breaks. You can use them all you wish to format your file, but the presence of a return in the code will not affect the rendering of the text. To insert a line break, you must include a tag for it. The line break tag is <BR>. There is no closing tag.

  16. Line spacing Try this example. <HTML> <FONT SIZE=3 FACE=arial COLOR=blue> Personality Research Lab </FONT> <BR><BR> <FONT SIZE=2 FACE=arial COLOR=blue> Welcome to our lab web page! </FONT> </HTML>

  17. Blank Spaces Blank spaces work in a similar way: Any space (greater than 1) that exists in the HTML code will not be rendered. If you want a sequence of blank spaces (e.g., for minor indenting), you have to include them explicitly. The command is &nbsp (Notice that this is not a tag per se, but it is still an HTML command. Nbsp stands for Non-Breaking Space.)

  18. Blank spaces Try this example. <HTML> Factor 1<BR> &nbsp &nbsp joy <BR> &nbsp &nbsp happy <BR> Factor 2<BR> &nbsp &nbsp sad <BR> &nbsp &nbsp shame <BR> </HTML>

  19. Centering Text To center text, use the <CENTER> and </CENTER> tags Try this example. <HTML> <CENTER>Personality Research Lab </CENTER> <BR><BR> The purpose of this experiment is to learn more about the way people understand others. </HTML>

  20. Creating Links A link is a portion of the page that, when clicked, automatically transports the user to a new page. HTML code: <A HREF=http://www.google.com>click here to go to Google</A> Note: The “A” stands for “anchor”. The HREF attribute is the URL for the page you want the user to go to when the link is clicked. The text in between the two tags will be what the user sees as the link.

  21. Creating Links Please note that, when the link leads to an external site (i.e., not your own), you need to include the full URL with the http portion. If the link leads to another webpage on your site that is located in the same directory (e.g., www), you only need to include the file name. Example: <A HREF=page2.htm>click here to go to the next page</A> Use this method whenever you can because it will make it easier for you to transfer files from one server or directory to another without rewriting the URL for all your links.

  22. Tables Tables are a valuable way to organize the placement of text on a web page. A few important things to know about the way table code is processed by browsers. - Row by row -Left to right

  23. Tables Any text that is placed in-between these tags will be rendered by the browser. Try this example. <TABLE> </TABLE>

  24. Tables The <TR> and </TR> tags are used to denote a new Table Row. <TABLE> <TR> </TR> </TABLE>

  25. Tables The <TD></TD> tags are used to denote a cell within a row. Any text that is placed in-between these tags will be rendered within that cell in the table. <TABLE> <TR> <TD> cell 1 </TD> <TD> cell 2 </TD> </TR> </TABLE>

  26. Tables A table with two rows. <TABLE> <TR> <TD> cell 1 </TD> <TD> cell 2 </TD> </TR> <TR> <TD> cell 3 </TD> <TD> cell 4 </TD> </TR> </TABLE>

  27. Tables Modifying table attributes: <TABLE BORDER=1> <TR> <TD> cell 1 </TD> <TD> cell 2 </TD> </TR> <TR> <TD> cell 3 </TD> <TD> cell 4 </TD> </TR> </TABLE>

  28. Tables Modifying table attributes: <TABLE BORDER=1 BGCOLOR=gray> <TR> <TD> cell 1 </TD> <TD> cell 2 </TD> </TR> <TR> <TD> cell 3 </TD> <TD> cell 4 </TD> </TR> </TABLE>

  29. Tables Please note that formatting needs to be applied within each cell. (A pain. I’ll show you a way around this later.) <TABLE BORDER=1 BGCOLOR=gray> <TR> <TD><FONT SIZE=10> cell 1 </TD> <TD> cell 2 </TD> </TR> <TR> <TD> cell 3 </TD> <TD> cell 4 </TD> </TR> </TABLE>

  30. Tables You can span across columns using the COLSPAN attribute. <TABLE BORDER=1> <TR> <TD COLSPAN=2><CENTER> Means </CENTER></TD> </TR> <TR> <TD> Group 1 </TD> <TD> Group 2 </TD> </TR> </TABLE>

  31. Tables Any text that is placed in-between these tags will be rendered by the browser. Try this example. <TABLE> <TR> <TD> cell 1 </TD> <TD> cell 2 </TD> </TR> <TR> <TD> cell 3 </TD> <TD> cell 4 </TD> </TR> </TABLE>

  32. Cascading Style Sheets (CSS) • One of the cumbersome aspects of formatting text in classic HTML is the sheer number of tags required to do so. If you choose to change the “style” of your web page after a period of time, all of the code needs to be rewritten. • This is especially inconvenient when working with tables because the text has to be formatted separately within each cell. • CSS provides a means for separating style from content and is an efficient way to add pizzazz (not pizza) and personality to your web pages.

  33. CSS Any text that is placed in-between these tags will be rendered by the browser. Try this example. <HTML> <style type="text/css" media="all"> body { color: white; background: gray; font-family: verdana; font-size: 14; line-height: 2; } </style> Welcome to my web page! </HTML>

  34. You can define “classes” so that different portions of your content are styled differently.

  35. <HTML> <style type="text/css" media="all"> body { color: white; background: gray; font-family: verdana; font-size: 14; line-height: 2; } .td1 { border-style: solid; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-color: black; background: white; color: gray; padding: 10px; } </style> Welcome to my web page!<BR> <TABLE> <TR> <TD class=td1> home </TD> <TD class=td1> research </TD> <TD class=td1> vita </TD> </TR> </TABLE> </HTML>

  36. CSS Adjusting the way in which links behave. <HTML> <style type="text/css" media="all"> a:link { color: blue; } a:visited { color: navy; } a:active { color: pink; } a:hover { color: red; background-color: blue;} } </style> Welcome to my web page!<BR> <A HREF=http://www.google.com>click here to go to Google</A> </HTML>

  37. Transferring your web page to the web server • Save your file with the *.htm extension. Example: mypage.htm • Go to the Netfirms web page and login to your account. • Go to the File Manager. • Click the “www” folder to open your www directory (i.e., the directory where your web pages will reside) • Click the “upload” button. • Find mypage.htm on your computer using the “browse” option. • Upload the file.

  38. Viewing your webpage • You should now be able to see your web page on the “live” Internet. • URL: http://mysite.netfirms.com/mypage.htm • Important note: You will be tempted to simply click on the link for your file from within the Netfirms File Manager. Don’t do it! It will not open your file naturally; it will try to open it in a secure way, which may cause your file to display improperly. To view your file, type the URL directly into the address bar in a separate browser window. As you make changes and trasnsfer the new file, you’ll need to REFRESH (F5) the screen to see the changes take effect.

  39. Notes about revising your page.

  40. Images You can use tags that enable images to be displayed on your web page. Here is the basic code: <img src=http://www.psych.uiuc.edu/~rcfraley/nauttext2.gif width=240 height=240 alt=‘main graphic’>

  41. Notice that there are several attributes that can be varied: width, height, and ‘alt’ (i.e., the text that appears when you hover your mouse over the graphic). • As with links, your URL can be absolute (i.e., including the full URL address for the image) or relative (i.e., just the file name, assuming the graphic file is in the same directory as the page calling it).

  42. Images If the image were in the same directory: <img src=nauttext2.gif width=240 height=240 alt=‘main graphic’> Images as background (http://www.w3schools.com/css/css_background.asp): <style type="text/css" media="all"> body { background-image: url('nauttext2.gif'); } </style>

  43. Images Using an image as a link: <A HREF=http://www.google.com> <img src=http://www.cs.cmu.edu/~wjh/go/go.gif alt=‘goto google’> </A>

  44. Image Cautions • Things people do wrong when working with images: • 1. They do not have the image file in the same directory as the web page that is displaying it. • 2. If they are using DreamWeaver, DreamWeaver has assumed that, since the image was on the C drive of the user’s computer, the web page code should try to pull the image of the user’s computer. This won’t work when the page goes live. • 3. People sometimes use images that are too big and resize them downward. Large image files take a long time to download even if they are displayed using smaller dimensions.

More Related