Jump to content


Starting with HTML, very basic stuff...


6 replies to this topic

#1 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 29 November 2007 - 19:58

This tutorial is going to show you how to make a basic webpage in html.
not jut the hello world" type either... thats a little too simple :P

first off open up a notepad file.


Doctypes
Thanks to CodeCat

a web page always requires a <!DOCTYPE at the very top of the file.

A minimal HTML file therefore looks something like this:
<!DOCTYPE html PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34; &#34;http&#58;//www.w3.org/TR/html4/loose.dtd&#34;>
<html>

<head>
<title>Page name</title>
</head>

<body>
Inset whatever you want here.
</body>

</html>

This page uses the HTML 4.01 transitional doctype, but you can leave out the 'transitional' (i.e. 'HTML 4.01//EN') to get the strict doctype. A strict doctype permits less old and deprecated features, but it does encourage you to write correct HTML.


And for XHTML, a minimal file (using the XHTML 1.0 transitional doctype, the principle is the same) would look like this:
<?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?>
<!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;>
<html xmlns=&#34;http&#58;//www.w3.org/1999/xhtml&#34;>

<head>
<title>Page name</title>
</head>

<body>
Inset whatever you want here.
</body>

</html>


Notice the use of the additional attribute on the <html> element as well as the <?xml declaration on the first line. The <html xmlns= attribute is required for XHTML, though the xml declaration is not (but recommended nonetheless, as it specifies the encoding type for the file).

There are quite a few more doctypes and other things, which you can read all about here: http://www.w3.org/QA...d-dtd-list.html




the very basics of html is=
<html>
<head>
<title>Page name</title>
</head>
<body>
Inset whatever you want here. 
</body>
</html>


explained:
the <html> tag tell your browser that this is the start of an html page. the </html> tells the browser tht it is the end of the html page.
the info between the <head> and </head> tag is just general information about the page, this will not show within the browser window.
The <title> tag is what will be displayed in the tab or that bar across the top of the browser.
The text between the <body> and </body> tags are what will be displayed in the browser.

Other useful tags include:

<h1>this is a heading</h1>

<h2>this is a smaller heading</h2>

<h3>an even smaller heading</h3>

<h4> I'm sure you get the idea</h4>

<p>a paragraph</p>

<br>this tag (break) will move you to the next line<br>

<!-- anything in this tag (comment) will be ignored by your browser -->



Links

The following code will display a link
<a href="url">Text to be displayed</a>

This will display an image
<img src="image url" alt="caption" />

This will display an image with the ability to forward the user to another webpage when clicked on.
<a href="url"><img src="image url" alt="caption" /></a>




Table

This will create a 2x2 table
the <tr> defines a row. The <td> tag defines a cell.

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

(thanks to codecat)
Text formatting

There are 3 different ways of styling an element:

1. By adding a style= attribute directly to the element, and writing the CSS code in the attribute's value. This is recommended only for one-shot styles, which aren't used anywhere else, and even then you're better off using an id= attribute instead.

2. By adding an class="classname" attribute to the element, and defining a style for it in a separate style sheet. Use this when several elements may share the same styling. The CSS then refers to this class with .classname .

3. By adding an id="idname" attribute to the element. This works similar to a class, however an id name uniquely identifies a specific object and can therefore only be used once. Use this for styling individual elements rather than a set of similar ones. The CSS refers to the element with a particular id with #idname .


For options 2 and 3 (the preferred and most-used ones), you'll need to write a separate style sheet. There's two ways of doing that:

1. Write the CSS code in <style> tags, inside the page's <head>. This is called an embedded style sheet.
<head>
<style type=&#34;text/css&#34;>
/* CSS code */
</style>
</head>


2. Write the CSS code in a separate .css file, and then link to the .css file inside the page's head. This is called a linked style sheet. (Note: all code I write is written in XHTML and therefore uses a self-closing tag)
<head>
<link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;link/to/file.css&#34; />
</head>





lists

Thanks to Prince Kassad

Unordered list:

<ul>
<li>Cook delicious cookies</li>
<li>Get a resupply of toxins</li>
<li>Invite friends</li>
</ul>



Ordered (numbered) list:

<ol>
<li>Get 200 milliliters of fuel, 1 cookie and a hungry friend</li>
<li>Pour the fuel over the cookie, then paint it so it looks somewhat like a cookie &#40;use brown paint from your water color box&#41;</li>
<li>Get your hungry friend over to the kitchen</li>
<li>Make him eat your special cookie</li>
<li>Wait five minutes</li>
</ol>






If you can think of anything else for me to add, just post. :/

Edited by Warbz, 29 November 2007 - 22:02.


Posted Image

#2 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 29 November 2007 - 21:05

I'd say it's better to just provide links to (X)HTML tutorials, but I suppose it doesn't hurt to improve this.

First of all, it's a good idea to explain the differences between HTML and XHTML. People often confuse the two. For example you use self-closing <img /> tag with alt= attribute like in XHTML, but you use the plain HTML <br> tag without self-closing.

Secondly, whether or not you're using XHTML, a web page always requires a <!DOCTYPE at the very top of the file.

A minimal HTML file therefore looks something like this:
<!DOCTYPE html PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34; &#34;http&#58;//www.w3.org/TR/html4/loose.dtd&#34;>
<html>

<head>
<title>Page name</title>
</head>

<body>
Inset whatever you want here.
</body>

</html>

This page uses the HTML 4.01 transitional doctype, but you can leave out the 'transitional' (i.e. 'HTML 4.01//EN') to get the strict doctype. A strict doctype permits less old and deprecated features, but it does encourage you to write correct HTML.


And for XHTML, a minimal file (using the XHTML 1.0 transitional doctype, the principle is the same) would look like this:
<?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?>
<!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;>
<html xmlns=&#34;http&#58;//www.w3.org/1999/xhtml&#34;>

<head>
<title>Page name</title>
</head>

<body>
Inset whatever you want here.
</body>

</html>

Notice the use of the additional attribute on the <html> element as well as the <?xml declaration on the first line. The <html xmlns= attribute is required for XHTML, though the xml declaration is not (but recommended nonetheless, as it specifies the encoding type for the file).

There are quite a few more doctypes and other things, which you can read all about here: http://www.w3.org/QA...d-dtd-list.html
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#3 Liliana

    natural power

  • Member
  • 645 posts

Posted 29 November 2007 - 21:26

View PostWarbz, on 29 Nov 2007, 20:58, said:

If you can think of anything else for me to add, just post. :P

Lists.

Unordered list:

<ul>
<li>Cook delicious cookies</li>
<li>Get a resupply of toxins</li>
<li>Invite friends</li>
</ul>


Ordered (numbered) list:

<ol>
<li>Get 200 milliliters of fuel, 1 cookie and a hungry friend</li>
<li>Pour the fuel over the cookie, then paint it so it looks somewhat like a cookie &#40;use brown paint from your water color box&#41;</li>
<li>Get your hungry friend over to the kitchen</li>
<li>Make him eat your special cookie</li>
<li>Wait five minutes</li>
</ol>

Quote

Anyway,the China's army is a modernize army,this army can bear down all country's army.
I hope SWR team can modification the China in the RISE OF THE RED and SHOCKWAVE mods.China is a modernize country.Maybe in thirty years later,the China will be a big and powerful country,overrun the US

Quote

[22:23:32] <J8a> why would i read a eula anyway?
[22:23:41] <J8a> they're not written in english
[22:23:59] <J8a> THEY ARE WRITTEN IN, BUT NOT LIMITED TO, CAPITAL LETTERS.

#4 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 29 November 2007 - 21:46

I'd also like to point out that <b> <i> and <u> are deprecated in favour of CSS styling attributes. Which is also a must to learn BTW.

There are 3 different ways of styling an element:

1. By adding a style= attribute directly to the element, and writing the CSS code in the attribute's value. This is recommended only for one-shot styles, which aren't used anywhere else, and even then you're better off using an id= attribute instead.

2. By adding an class="classname" attribute to the element, and defining a style for it in a separate style sheet. Use this when several elements may share the same styling. The CSS then refers to this class with .classname .

3. By adding an id="idname" attribute to the element. This works similar to a class, however an id name uniquely identifies a specific object and can therefore only be used once. Use this for styling individual elements rather than a set of similar ones. The CSS refers to the element with a particular id with #idname .


For options 2 and 3 (the preferred and most-used ones), you'll need to write a separate style sheet. There's two ways of doing that:

1. Write the CSS code in <style> tags, inside the page's <head>. This is called an embedded style sheet.
<head>
<style type=&#34;text/css&#34;>
/* CSS code */
</style>
</head>


2. Write the CSS code in a separate .css file, and then link to the .css file inside the page's head. This is called a linked style sheet. (Note: all code I write is written in XHTML and therefore uses a self-closing tag)
<head>
<link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;link/to/file.css&#34; />
</head>



For more information and stuff about CSS, see here: http://www.westciv.c...y/css_tutorial/
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#5 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 29 November 2007 - 21:51

thanks prince kassad,
@codecat
I was just trying to keep it simple for now. Thoughh i suppose that is technically the correct wahy.

Posted Image

#6 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 29 November 2007 - 21:53

Keeping things simple is allright, as long as you don't teach things and then turn around and say it's really wrong and it should be done another way. Teach it right the first time.
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#7 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 29 November 2007 - 22:03

*updated*

Posted Image



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users