Saturday, December 31, 2011

Building a Site With CSS3

Introduction

This post will go over my naive implementation of a style sheet to build the "Chicken Sandwich" page, as it is currently implemented.  As mentioned in the previous post, this site functions well under all the major browsers (IE9, Firefox, Chrome, Safari).  IE9 currently doesn't support the gradient in the background (to my knowledge) so It uses a fallback of a solid color background that is somewhere between the two values in the start/end gradient you see in the other browsers.

There are many ways to style your web page elements.   Step one is to identify the element you want to style.  This can be done by referencing either the element as it's known by the DOM, the element's class, or it's id.

So let's take a look at the "div" element <div> in HTML.
<div class="divider" id="divStyle"> This is my Divider</div>
If I want to identify this object in my CSS file, I can do that four  ways. (to my knowledge)

div{} - assigns default style to all elements of this type.

div.divider{} - assigns style to all div elements with the class "divider" set by <div class="divider">

.divider{} - assigns the style to all elements with the class set to "divider" set by <element class="divider"> This could be anything defined by the user. For instance:

.hamburger{} -- <element class="hamburger">

#divStyle{} - assigns style to the element who's id is "divStyle". Set by <div id="divStyle">

Most of the time the id for an element is going to be unique and this method should be applied to elements who have their own unique style, not for general style settings.   A good design rule would be to stylize your elements through their class, and only use the id reference for edge cases where you need a one-off style for a unique element or element that derives from a class of elements.

So let's get started.   

The first thing everyone wants to know is, "how do I position elements on my page in an aesthetically pleasing way?"  

 Well, first you have to have an aesthetically pleasing design, which we can go over at another time, but for now let's assume that you have a design in mind.  

You'll want to put it together in a program similar to Photoshop, or at the very least sketch it out on paper.  Designing in an graphical program is benificial because you have the advantage of getting measurements and color data from the images you create.  Also, you'll want to create some images yourself anyhow, and not rely solely on clip art and images you find off the web. 
That in mind, you don't want your website to be too image heavy because these types of graphics take longer to load than elements generated through CSS and script (sometimes).


Containers

All web pages should have a main container.  This container can be any element that wraps around the content and establishes the main dimensions of the page.
In this example, we'll be using a <div>.
Dividers are awesome with the power of CSS.  Basically everything that used to be done using tables can now be done way easier and cleaner with a <div> element.
We'll start by opening up our basic HTML and adding a <div> in the body of the page.
<body>
                 <div class="container" id="master">
                 </div>
</body>
Notice the class is "container" and the id is "master"
Now we need to add the CSS block for this container to our stylesheet.
In this particular instance it's ok to reference it by the ID, because there will be only one "master" div for our template, but there could be many "container" divs.
This should be what your stylesheet looks like at this point:
html{
background:#e00000;
height:100%;
background:-moz-linear-gradient(top,#fe471d,#e00000) no-repeat #e00000;
background:-webkit-gradient(linear,left top, left bottom, from(#fe471d), to(#e00000)) no-repeat #e00000;
font-family: "helvetica", Arial, sans-serif;
color:#000;
}

body{
margin:auto;
height:100%;
}

#master{
}
Open it up in your browser and take a look.
Pretty unremarkable, I know... but hey, it's a start. 

Notice the div isn't visible.  This is because we have both, no content, and no style.

Type some text between the <div> tags, and reload the page. 

You'll notice the content shows up just like it would if you had just put it in the body tag.  That's because elements like the <div> element take on the properties of the element they are a child of.  So if you have a style set for the <body> unless the element the content is contained within has its own stylesheet data, the content will at like it's parent.  This makes sense, how else would the element get formatting information if not from the element it is contained within?

So let's add some style to the divider!
#master{
width:900px;
min-height:85%;
margin:auto;
padding:20px;
background:#ffffff;
}
Now take a look.


We've told the master div element to take on the following properties:

Width of 900 pixels.  This makes sure the content is contained within the standard visible space of a page, for most devices.  Anything larger and you run the risk of the page looking cramped on some devices.

Minimum height of 85% of the body, so that it doesn't go all the way to the bottom of the screen, but it will not be too high on the screen in cases where we have very little content.

Automatic margin is basically saying, "center my business to the parent" in this case, the parent is the body, which is basically the document.  In some cases you may have more than one body, and this would change.

padding of 20 pixels will make sure that all the content of the page will be 20 pixels away from the edge of the element.

And finally, the background is white.

Moving Our  <DIV>

I don't care for having the div element at the top of the page, so let's move it down a bit.  This is simple enough to do, all we have to add to our css is the following line:
top: 20px;
This will move the div element down 20 pixels.

oh, but wait, It won't!

because out element's position attribute is not defined.

there are three types of positioning:
fixed - absolute - and relative
for this example, we will set the div element position to relative by adding the following line to our CSS:
position:relative;
Easy enough, right?  reload the page and see what happens.  If it doesn't work, make sure your css looks like so:
#master{
background:#ffffff;
position:relative;
width:900px;
min-height:85%;
padding:20px;
margin:auto;
top:20px;
}
None of these attributes require a specific order, but some do.  It depends on what you're trying to achieve.  This is particularly true in the case of some vender specific attributes, like the ones mentioned earlier that require the prefix -moz- and -webkit-.  Usually this only matters in IE because IE is awful.

Adding a Border

Adding a border is easy to do, and should be done with minimalism in mind.  Less is always more.  In this case, I'll add a solid black border of 2 pixels.
Add the following line to the #master css.
border:2px solid #000;
What?  It's boring?  Ok, fine, let's add borders for the top, left, right and bottom of different thicknesses.
border-top:1px solid #000;
border-left:1px solid #000;
border-right:3px solid #000;
border-bottom: 5px solid #000;
Looks a bit better yeah?  Well, how bout a shadow?  That's right, the latest iteration of CSS provides you with the ability to add shadows to your situations.  And it's easy, and supported in nearly all browsers.
Try this:
box-shadow: 20px 20px 15px rgba(0,0,0,0.5);
This will add a boxed shadow on the element that is offset on x 20 pixels, on y 20 pixels, blurred 15 pixels, and with the color of black.  The rgba color format also allows you to specify an opacity, which is 0.5 (or 50%) in this example.

After you see the effect you can tweak it.  But here it is in case you don't feel like writing all this code.


Adding Layered Effects

Now let's add a div within this div that will float underneath and serve as a "menu" or something.
replace your text with another <div> element.
<div class="menu" id="leftMenu">
Copy and paste your #master css block and change the #master portion as follows:
#master --> .menu
and change the dimensions and what-not to be what you'd like.  I changed them to 200px and 200px to start with.  Remove the formatting of the margin as well, this will push the div to the far left of the parent (left justified being the default of the browsers).  I also changed the padding to 5px.  My css now looks like this:

#master{

                background:#ffffff;
                position:relative;
                width:900px;
                min-height:85%;
                padding:20px;
                margin:auto;
                top:20px;
                border-top:1px solid #000;
                border-left:1px solid #000;
                border-right:3px solid #000;
                border-bottom: 5px solid #000;
                box-shadow: 20px 20px 15px rgba(0,0,0,0.5);

}

.menu{

                background:#cccccc;
                position:relative;
                width:200px;
                min-height:200px;
                padding:5px;
                top:20px;
                border-top:1px solid #000;
                border-left:1px solid #000;
                border-right:3px solid #000;
                border-bottom: 5px solid #000;
                box-shadow: 20px 20px 15px rgba(0,0,0,0.5);

}

Save and reload your page, and it will now look like this:


Blowing Your Mind

This next part may blow your mind, so I suggest you be setting down.  If you're not already, we need to have a different discussion...
We now want to position this div offset from the main body.
Let's do that by adding the following line to the css of the menu block.
left:-200px;
It's that easy...
Z-Index
To change the depth of your elements, we need to add formatting for the "z-index".  Z-index is commonly used to describe the location of objects in the "depth buffer" for most renderers and APIs.  Z refers to an axis.  And when thinking about the elements in your document you should think of them in terms of how they relate to 3d space.  x being left to right, y being up and down, and z being forward and back. 
Add z-index information for both the menu and the master dividers.
#master{
      z-index:20;
}

#menu{
      z-index:19;
Notice the z-index isn't 1 and 2.  This is because we may want to add background elements, and if we make them 0 and 1, it will make it more difficult to go back and change our indexes once we have more blocks of css.

OH BUT WAIT!!!

This isn't going to work!  Because the div doesn't have anything to sort against.  The z-index of an object is always inherited from its parent.  Starting to see a pattern?  So before we can affect the sorting of these elements relative to one another, we need to pull the formatting from the master div and create a "content" div to put within it.  This makes sense for several reasons.  We don't want to rely on our master div for any visual elements, but rather to use it as the container.  Visualizing it initially is good for debugging purposes, and with the copy paste technology, we haven't wasted any work.  SO let's create our content div css block by copying the master div block.  Then add a <div> for content in the master div...

So, this is what our css looks like after making the appropriate changes.  This included:
·         removing padding from master, since there was no content in it.
·         copying and pasting master and changing the #master --> .content
·         removing all visual formatting from the #master css.

#master{


                position:relative;
                width:900px;
                min-height:100%;
                padding:0px;
                margin:auto;
                top:20px;


}

.menu{

                background:#cccccc;
                position:relative;
                width:200px;
                min-height:200px;
                padding:20px;
                top:20px;
                left:-200px;
                border-top:1px solid #000;
                border-left:1px solid #000;
                border-right:3px solid #000;
                border-bottom: 5px solid #000;
                box-shadow: 20px 20px 15px rgba(0,0,0,0.5);
                z-index:19;

}

.content{

                background:#ffffff;
                position:relative;
                width:900px;
                min-height:85%;
                padding:20px;
                top:0px;
                left:0px;
                border-top:1px solid #000;
                border-left:1px solid #000;
                border-right:3px solid #000;
                border-bottom: 5px solid #000;
                box-shadow: 20px 20px 15px rgba(0,0,0,0.5);
                z-index:20;

}

And this is what our document looks like now...



Not exactly what we had in mind?  Hrmm... ok... 

That's because our positioning isn't right for our "content" divider.  Changing the "position:relative" to "position:absolute" will fix this problem.  

The definitions of the 3 different positions will be explained later on (as i get a better understanding of them) but for now, just do it, and you'll see what I mean.

I've read a few definitions of the three positioning rules, but haven't fully wrapped my head around it in a way that will allow me to break it down one time (so to speak.)

So here's what you've got after all that jazz!


With these techniques, I've created this page:


I'll do more complex and aesthetically pleasing stuff later, but for now, this will do.

Hope you've enjoyed the read, and if there are ways I can improve it, or any errors you can spot, please let me know by adding a comment or sending me message!

Cheers!

Friday, December 30, 2011

Progress Report


Above is a shot of the website I've developed up to this point.  All the elements are static, but I'd say after only a couple of days learning this business, we're looking pretty good so far.

This will be the main page for our "Games site"... Once we get this turd polished up and get adding content to the site somewhat pain-free, we'll start working on the actual game.

This site is basically a bunch of Div's that are positioned and formatted with CSS3.  The site currently functions well under Firefox, Chrome, Safari, and IE9.  The goal of any successful website design/implementation should be to function under these 4 browsers at a minimum.

Tomorrow I'll post on how to position DIV elements using CSS3.

Externally Referencing CSS

So the great thing about the way web applications are developed now (sites,games,google,youtube), is that everything is separated.  So you can keep your HTML in one file, a CSS in another file, a JavaScript in a different file.  You can even put them in their own folders.  This is important, because if you don't do this, your shit's going to get all big and shit son.

Separating your css and scripts into their own folder/file makes it super easy to navigate through the different parts of your project and makes your files easily readable.

So let's pull our CSS out of the html file and create a .css file.

Copy everything between the <style> </style> tags and put them in a new document.  Save this file in a folder called "css" relative to your .html file.  save it as "pagestyle.css" or whatever you want.  If you name it something different than pagestyle.css, you'll need to change the code in this example to reflect that difference.

after you've saved your file, you'll need to delete the <style></style> tags... or don't... this doesn't matter, but I like to delete shit that I'm not using to keep my file clean.

Now my file looks like this:

<!DOCTYPE HTML>
<html>
     <head>
         <title>
            Title of my project: A learning experience.
         </title>
  
     </head>
     <body>
           ANYTHING!!!
     </body>
</html>
Look familiar?  Yeah, thought so.

So now add the <link> under <title>  This will be where we "link" the css to the html file.

      <link rel="stylesheet" href="css/pagestyle.css">

the "rel='stylesheet'" portion of this line tells the page what relationship the linked content has to the page.  This is important.  Otherwise the page wouldn't know what to do with the linked content.
... href="css/pagestyle.css">
This portion of the link is the location.  This tells the page where the content is stored relative to the content.  This can very well be another www.whateversiteyouwant.com/location/file.extention if you'd like... but since the file is not stored externally, you won't need to go through all that business.

Save your html file and reload it in your browser.

Looks the same? good.  If not, make sure your html file looks like this:

<!DOCTYPE HTML>
<html>
     <head>
         <title>
            Title of my project: A learning experience.
         </title>
         <link rel="stylesheet" href="css/pagestyle.css">
     </head>
     <body>
           ANYTHING!!!
     </body>
</html>
and make sure you saved your css file the correct location, and that it looks like this:

html{
    background:#e00000;
    height:100%;
    background:-moz-linear-gradient(top,#fe471d,#e00000) no-repeat #e00000;
    background:-webkit-gradient(linear,left top, left bottom, from(#fe471d), to(#e00000)) no-repeat #e00000;
    font-family: "helvetica", Arial, sans-serif;
    color:#000;
}
If it doesn't work and the contents of your pages are as shown above... I got nothin'. and you should probably not be developing web content. :).

But now, if you want to change the style of your page, you simply need to change the .css file linked to the page, and you're ready to go.  Coming up, we'll talk about classes, JavaScript, changing style through JavaScript, and making functions to do that stuff.

Cheers, and good luck!

Change Dem Fonts

So you wanna change your font face.  That's cool...

html{
     font-family: "Helvetica", Arial, sans-serif;
}

In this style example, font-family is what we're changing.  We're changing it to "Helvetica" with a fallback to "Arial" and a general family fallback of "sans-serif"

I've tried changing it to just one of the above and it looked the same for all three.

As soon as you put something in there that is invalid, it will make the font whatever your default font is in your browser.

You can change the font styling for ever element.

If you want to change the color of the font, you can do that by using:

"color:#fff;" or "color:white;" or "color:rgb(255,255,255);" or "color:rgba(255,255,255,255);"

and the old: "color:#ffffff" - full hex.

The difference in the above examples is roughly 0.  but if you want to change the opacity, you'll want to use rgba, if you want to make sure the color is 100% web safe you should use  full hex.  #fff is a simplified version of the same thing, and is useful if you don't need to make a crazy color.  I prefer using the full hex which is easy enough to get from Photoshop or any other half-decent painting/photo manipulation software.

Have fun!

Follow The Project

You can follow the progress of the entire project here. 


Snippets and things we're testing will be put in their own HTML files, but the general project can be found at the link above.

Add Some Style(sheets)

Congrats if you made it this far, you've successfully created an HTML document that looks like dog balls.  We all know you're creative and want to add a little bit of your own personality to this business.  So let's get started learning CSS3, which is essentially the way we'll change nearly every single visual element of our web game and page containing it. 

CSS3 is wicked powerful and is capable of doing animations and all kinds of stuff.

We're going to add a background gradient... and then some more pretty shit... so let's do this.

We'll start by looking at the thing we're trying to create:

CSS3 Gradient Tutorial :

And yes, I'm aware that it still looks like dog balls.  But there is most definately a gradient on this page.  So how did we do this?

<Style> Tag

The style tag is used to define (inside an html file) the style of the page.  For this part of the tutorial, we'll use this method.  So the first thing you'll need is to add <style></style> tags to your existing document (from the previous post, or whatever html document you're adding style to).  This should make your document look like:
<!DOCTYPE HTML> <html>
     <head>
         <title>
            Title of my project: A learning experience.
         </title>
         <style>

         </style>
     </head>
     <body>
           ANYTHING!!!
     </body>
</html>
Now everything that you put between the <style> and </style> tag will be interpreted as CSS (cascading style sheet) data.  You can google, "why they call it cascading style sheet" if you want, but it's not terribly interesting, and doesn't really provide you with any more information than the name itself does.

Changing Appearance of Page Elements

You can change nearly every visual aspect of your page with CSS.  The only thing required is to know the "class" of the element as it is specified in the markup, script, or standard elements available through the DOM. (I think that's right).  So basically if you want to change the background of the body of a page, you can do that.  If you want to change the background of a paragraph you can do that.  If you want to change the... you can do that.

But how?

Simply tell the CSS which element you want to change and add {} after it like so:

body{}
Now, everything between the {} will be interpreted as CSS for that specific element.

There are all kinds of things you can change about the element, but for this example we will stick to the background: attribute.

body{
     background: your-style-goes-here ;
}
And "your-Style-Goes-here"; is not proper syntax for anything (duh).  But there's some things to explain about syntax for CSS stuff.  CSS is one of those things that isn't standardize across browsers yet.  This is because the different browser venders haven't been able to agree on what the best way to do it would be (I think).  But as soon as they do, this shit's all going to change.  Personally, I'd think it would be pretty easy to get the shit standardized, but whatever, we'll talk about that another day.

The point is, when dealing with CSS3 you'll want to make sure you're putting CSS code in your style sheet to handle all the browsers you plan on supporting with your site, or at the very least a nice fallback for all browsers you don't want to worry about.  

In the case of gradients, they are a relatively new addition to CSS and you basically have to do it twice for that reason... but luckily only once.  When we're done with this tutorial you'll be able to make one style sheet for all your pages.  This is how templates are made.

The Gradients
-moz-linear-gradient
-webkit-gradient

I'm sure there's different ways to do it in Opera and IE but fuck those browsers... they can use the fallback of a solid color. (basically I googled it, and it was way to difficult to explain and wasn't even CLOSE to the same way it's achieved in the cool browsers.)

-moz- basically says "Hey, CSS, this is a Mozilla specific joint, ignore for other browsers, and the same for -webkit- which is basically Safari and Chrome.

You're going to see this alot (until they all get their shit together)... these are referred to as different things, but mainly as vender specific markups (at least in my readings).

So now for the actual gradient.  We'll do moz first, since It's my favourite browser.

-moz-linear-gradient(top,#ccc,#000);

The above line basically says, "hey mozilla, make a linear gradiant starting at the top and with the color of this crappy grey and go to black".

Sounds simple enough.

Then there's -webkit-

-webkit-gradient(linear,left top, left bottom, from(#ccc), to(#000));

This basically says the same thing, but says it like this... 

"Yo, uhm... ok... look webkit browser... this is what I want you to do... i think.. Uhmm.. yeah.. so let's make a gradient.  Ok... Uhh... linear.. yeah.. linear.  And should we start it at the left corner?  Sure... ok... left corner.  Oh fuck.. that's right.. left top corner.  Ok.. now uhhh.. go to the bottom left corner.  Wait, what?...  whatever... ok... let's make it start at a shitty grey... and go to ... black.   Ok, cool.. yeah I think that'll do.. Thanks webkit browser!"

There's actually good reason the webkit version is more verbose.  It's not easy to read, because it doesn't make sense to people, but it makes sense to the computer.  This method of doing the gradient leaves room for scalability of the feature, as well as gives a more literal representation to the browser. (This is all assumption at this point, and should be interpreted as nothing more than bullshit... and you should probably have skipped to the next section by now).

So what does it look like now?

Still looks like dog balls huh?  Hrmm... well let's look at our document.

<!DOCTYPE HTML> <html>
     <head>
         <title>
            Title of my project: A learning experience.
         </title>
         <style>

                body{
                      background:-moz-linear-gradient(top,#ccc,#000) ;
                      background:-webkit-gradient(linear,left top, left bottom, from(#ccc), to(#000));

                }

         </style>
     </head>
     <body>
           ANYTHING!!!
     </body>
</html>

Well, by now, you're noticing that the gradient is stopping after your content and repeating forever many times down the length of your document.  This sucks.  So to fix this you need to add "no-repeat" to your style.  This is because your computer and the internet will assume nothing about the instructions you give it.  This is the most valuable lesson I've learned... The computer will ASSUME NOTHING!... 

so go ahead and change the gradient lines to include "no-repeat" after the last ) and before the ;
background:-moz-linear-gradient(top,#ccc,#000) no-repeat;
background:-webkit-gradient(linear,left top, left bottom, from(#ccc), to(#000)) no-repeat;

luckily, they've agreed on this part.  

But it still looks terrible and is only covering the content...

That's because it's important to remember that the body of your page is only as long as the content within it.  And in order to make sure your background fills the page, you need to give the thing that's wrapping around the entire document the style declarations.  This wrapper would be the <html> tag.  

So change body to be html.

<!DOCTYPE HTML> <html>
     <head>
         <title>
            Title of my project: A learning experience.
         </title>
         <style>

                html{
                  background:-moz-linear-gradient(top,#ccc,#000)  no-repeat ;
                  background:-webkit-gradient(linear,left top, left bottom, from(#ccc), to(#000)) no-repeat;

                }

         </style>
     </head>
     <body>
           ANYTHING!!!
     </body>
</html>

And for good measure, we want to add a background color to these tags, and a fallback background color.  This fallback background color should exist before the gradients, because we want the gradients to be the last thing applied.
<!DOCTYPE HTML> <html>
     <head>
         <title>
            Title of my project: A learning experience.
         </title>
         <style>

                html{
                  background:#222222;
                  background:-moz-linear-gradient(top,#ccc,#000)  no-repeat  #000;
                  background:-webkit-gradient(linear,left top, left bottom, from(#ccc), to(#000)) no-repeat #000;

                }

         </style>
     </head>
     <body>
           ANYTHING!!!
     </body>
</html>

And that should just about do it for the gradient.  Try opening it in different browsers and changing the background colors to get a cool gradient you like. 

And remember these lessons (I know I will):
  • The browser assumes nothing
  • There is always more than one way to skin a cat and no two venders will agree on which way is the correct way. -moz- vs -webkit- vs -ms- vs -o-
  • The body element is only as long as is specified in the HTML or is defined by the content
  • CSS3 is powerful shit.  Start reading up on it.
Thanks for reading!

  

Thursday, December 29, 2011

Discoveries 1.0.1

Getting Started
The first thing I discovered is how much things have changed in web development over the past 5 years.  I haven't really done much in the way of building applications, but simply have put together quick bullshit websites for various portfolios needing to be shown to get jobs.  This never required any extensive scripting, and was always a means to an end.

So the first thing I really discovered was how little I know.

So, first things being first, I needed to figure out how to write up my initial .html file.

This was relatively easy.  All you gotta do to learn this is google "standard html file" or something like it.

also, the most valuable resources have been:

Most Valuable Resources:
  • http://www.w3schools.com/ - these are the guys responsible for standardizing the web.  They seem to know what they're talking about to.  So the first thing you want to do is read everything you can on this page (even if it seems irrelevant to your project at this point, you'll want to be familiar with this websites content).
  • http://stackoverflow.com/ - number two on my list, and should probably be number one - this site is basically the yahoo answers for web developers.  Nearly every post is useful in some way, and nearly every question has some intelligent response (if it doesn't, just wait for it).  Lots of cool shit on this page.
  • http://www.google.com/ - when it doubt, google it.  Google will likely send you to stackoverflow.com, but it also points you to other stuff that's useful, and even stuff that you didn't know was going to be useful.
With these three resources, you should be able to learn just about everything there is to know about web development.  More resources to be added as they come to mind...

Basic HTML Document

DocType
So basically, what I learned (and kinda already knew) was that you need to first declare your document type.  This is simple (so far) and all you need is to write at the top of your document:

<!DOCTYPE HTML>

I don't think it needs to be capitalized... i just like how it looks... and don't forget the "!".  It's important.  That's why it's a "!"... you dig?

HTML Tag

Second thing is to define your html element...
<!DOCTYPE HTML>
<html>
</html>

Pretty simple right?  So the next thing you need to do is add the <head> and <body> elements...

Head Tag

The <head> element basically acts as a container for stuff that isn't to be displayed to the user, but rather describes how the browser should interpret those elements, interact with those elements, and where the page should look (externally) for that information... so if you want to reference something externally, like a script or a style sheet, it's best to do it in the head element.  For more information on the head element you can visit: http://www.w3schools.com/html/html_head.asp

Body Tag

The <body> element is the contexts of your page... like the body of a letter.  For more information on the body element you can visit: http://www.w3schools.com/tags/tag_body.asp

Both of these are written between the html tags: <html></html>...  when an element is defined within these tags, it's referred to as "wrapping", or using a "wrapper".  You can imagine these tags as bookends, or arms that wrap around everything that's between them, and effectively holding it all together.

Opening and Closing Tags

<> = open tag.
</> = close tag.

When an open tag is used, you almost always have to use a close tag.

There are very few exceptions to this... so few that it's safe to assume there are none.

Your document now looks like this (if you've done it correctly).

<!DOCTYPE HTML>
<html>
     <head>
     </head>
     <body>
     </body>
</html>

Formatting your "code"

I like to indent my html tags, because it makes the document much easier to read.  This is called "formatting" in some circles.  Having readable HTML, CSS3, and JavaScript documents is going to be crucial to maintaining productivity and navigability when working through various functions and debugging your work.

General rule:  if it's a child, indent it.

Sometimes this can get messy, but if your situation is getting messy, you need to rethink how you're structuring your project.  We'll talk more about this later on.

Now, if you load up your document, you'll notice it says "untitled" in the tab.  This is bullshit, and we should change it.  To do this, we need to add the <title> element which will describe the text that is in that tab, and also may be referenced elsewhere, but I haven't found any other use for it.

<title> elements must be a child of <head>.  So with that information our document now looks like this:


<!DOCTYPE HTML>
<html>
     <head>
         <title>
            Title of my project: A learning experience.
         </title>
     </head>
     <body>
     </body>
</html>
Now we want to add some content to the page.  This is done by adding anything between the <body> tags. 

<!DOCTYPE HTML>
<html>
     <head>
         <title>
            Title of my project: A learning experience.

         </title>

     </head>
     <body>
           ANYTHING!!!
     </body>
</html>

That's pretty much it for the basic HTML document requirements.  The next post will deal more with linking our CSS3 style sheets, JavaScript, and our init() function; which will initialize the app for us.  Also, we will go over the design of our "game".

Thanks for reading!

And so it begins... or has begun... whatever.

I've recently started delving into HTML5 learning CSS3, JavaScript, and the new HTML5 standards; which include Canvas and other nifty elements.

First off, I am not a programmer by trade.  I am an artist.  To be more specific, an artist in the video game development industry for the last 10 years (or so...).  I've always been fascinated by web development and the types of things that can be done in browsers using very simple interpreted script languages or markup languages like JavaScript and HTML.  With the recent additions of Canvas element to the HTML5 elements and the power of CSS3 combined with JavaScript, I thought it would be cool to try to make some games for the various browsers and document that process.

The goals:
  • Learn something (most important)
  • Share something (secondary)
  • Make fun games that people like to play (unlikely)
  • Make the development process visible to those watching (probably none)
  • Share problems encountered and solutions to those who may be trying to do the same thing.
  • Learn some more
  • Share the learning process I use for just about everything.
I hope you enjoy the blog and more importantly hope that it is useful.  Your feedback is appreciated, and any suggestions will be implemented (if not implemented considered) and blogged about here.

Thanks for reading!  And good luck in your own projects.