Saturday, January 14, 2012

#3 - xHTML Guide : Starting With Your First Code






Alright, here’s the beginning of the journey. Let’s start with just putting something on
the screen on this web page. First you’ll need to know what <tags> are.
XHTML code uses start and end tags to sort out what is going on with each element
of the page.


Here is an example of a start tag: <html>
Here is an example of an end tag: </html>



One has the element name enclosed in the pointy brackets and
the other is the same but has a slash before the element name.



IMPORTANT: You must close a tag after you open it at some point in the code. Also
tags must be nested, that is, meaning that you cannot do the following: <p> <body>
</p> </body>; it should be <body> <p> </p> </body>. 


The best way to get to know how to program is by actually doing it, so enough
theory. Just for a point of reference, I’m going to label each line of code with a
number so that I can explain line by line what is going on.


‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
1 <?xml version = "1.0 encoding = "utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <body>
6 <p> Hello World, this is my first page! </p>
7 </body>
8 </html>
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’


In line 1 I have stated the html code and in line 5 I have ended it. Inside the <html>
tag is the <body>, and inside the <body> there is a paragraph (line 3, <p>). If you
open this in a web browser, then you will see the following come across the screen:




If you want to change the title of the page from the browser’s point of view (eg.
firstpage.html) then you can easily add in the following line of code:


<title> Enter Title here </title>


This will make your webpage look more professional.



0 comments:

Post a Comment