<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michael Ramsey - The Website!</title>
	<atom:link href="http://michaelramsey.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelramsey.ca</link>
	<description>This is a Tagline?</description>
	<lastBuildDate>Mon, 01 Aug 2011 21:37:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Learning PHP &#8211; Part 3: Variables</title>
		<link>http://michaelramsey.ca/web-dev/php/learning-php-part-3-basics-continued/</link>
		<comments>http://michaelramsey.ca/web-dev/php/learning-php-part-3-basics-continued/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 19:58:27 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[PHP Basics]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=366</guid>
		<description><![CDATA[Gen. Jose Hernandez (from The Commons) Well, somehow I managed to let more than a month slip by without getting this post up. Between being quite busy for a lot of the time, and a bit of procrastination it was easy to fall behind. I've been making progress off and on through PHP and MySQL [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;"><a href="http://mokembo.com/general-posts/learning-php-part-3-basics-continued/"><img src="http://mokembo.com/wp-content/uploads/gen-k-hernanzed.jpg" alt="" title="gen-j-hernanzed" width="403" height="500" class="aligncenter size-full wp-image-367" /></a></p>
<p class="aligncenter" style="margin-top:0;"><a href="http://www.flickr.com/photos/library_of_congress/3491628454/" target="_blank">Gen. Jose Hernandez</a> (from The Commons)</p>
<p>Well, somehow I managed to let more than a month slip by without getting this post up. Between being quite busy for a lot of the time, and a bit of procrastination it was easy to fall behind. I've been making progress off and on through <i>PHP and MySQL for Dynamic Web Sites</i>, but with the extremely hot weather in Toronto lately, it has been difficult to get any reading done on the subway sometimes.</p>
<h2>Scalar Variables</h2>
<p>Variables are the subject of this long delayed post. Variables are used in PHP in much the same way that they are in virtually any other major scripting or programming language. Variables use in PHP is fairly informal. A variable's name must start with a dollar sign and be followed with a letter or underscore (e.g. <i>$variable</i>); beyond that it can be called more or less whatever you want. Unlike in some other languages, variables can be created on the fly, and don't have to be declared or initialized beforehand.</p>
<p><span id="more-366"></span></p>
<p>The equals sign (=) is used to assign a value to a variable. So <b>$first_name = 'Mike'</b> would assign the value <i>Mike</i> to the variable <i>$first_name</i>. A double equals (==) is used to check if two values match, an important distinction to remember, as mixing the two up will cause all sorts of issues and may not be that obvious at first.</p>
<p>At the most basic level, variables can contain 4 types of scalar variables: string, float (floating point number), integer or boolean.</p>
<p>A string can be any set of characters, like <i>Mike</i> in in the example earlier, or the entire text of this post, or a date among many other examples. Two strings can be concatenated (stuck together) using a period. Also, there are many functions related to working with strings in PHP.</p>
<p>A variable that contains only numbers can be treated as a string as well, but it differs from a variable containing a string in that there are also many number specific functions and operators as well. The obvious example is basic arithmetic, the basic operators for which are +, -, *, /, % (modulus), ++ (increment) and -- (decrement). Depending on the type of number it will either be stored as an integer or a floating point number.</p>
<p>Finally, boolean variables store a simple true/false value. This has many useful applications, such as storing whether or not a form has been filled out on a page that either displays or handles a form.</p>
<h2>Some other notes about Variables</h2>
<p>Another important basic variable to be aware of is constants. Once defined, these variables cannot have their value changed within a script. Examples of information that would be stored in constants are the site name/domain in WordPress or PHP's internal system information. Constants are differentiated from regular variables by not using a dollar sign at the start of their name.</p>
<p>One final aspect to mention is arrays. An array is a variable with more than one value assigned to it. Again, this is a concept that is present in other popular scripting/programming languages. I'll leave more explanation of arrays for when I'm actually working with them.</p>
<p>Obviously, this is a very basic explanation of variables. I'll talk more about them as I go over working through the exercises and projects I'm working on to learn PHP. </p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/php/learning-php-part-3-basics-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Update On Things In General</title>
		<link>http://michaelramsey.ca/general-posts/quick-update-general/</link>
		<comments>http://michaelramsey.ca/general-posts/quick-update-general/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 19:24:18 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[General Posts]]></category>
		<category><![CDATA[general ramblings]]></category>
		<category><![CDATA[starcraft2]]></category>
		<category><![CDATA[teamfortress2]]></category>
		<category><![CDATA[video games]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=376</guid>
		<description><![CDATA[Classing Sheep (from The Commons) I've been putting off getting my next PHP post up for awhile now. Things just seem to keep getting in the way. At work I've been either out or working through my lunches, and at home I've been busy with budget stuff and Emily looking for a job among other [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;"><a href="http://mokembo.com/general-posts/quick-update-general/"><img src="http://mokembo.com/wp-content/uploads/classing-sheep.jpg" alt="classing-sheep" title="classing-sheep" width="500" height="370" class="aligncenter size-full wp-image-377" /></a></p>
<p style="text-align:center;"><a href="http://www.flickr.com/photos/powerhouse_museum/2485155550/" target="_blank">Classing Sheep</a> (from The Commons)</p>
<p>I've been putting off getting my next PHP post up for awhile now. Things just seem to keep getting in the way. At work I've been either out or working through my lunches, and at home I've been busy with budget stuff and Emily looking for a job among other things. Part of it is that I wasn't able to get access to all but the most standard ports for internet traffic at work, which stopped me from doing any MySQL stuff. Anyway, I've hardly forgotten about my project. I've had an opportunity to work on some PHP stuff at work for our website. So at least things haven't fallen completely by the wayside this last couple weeks.</p>
<p>I figured to keep the site active I'd put this post up, and talk about a variety of random stuff in it. One thing I'd like to talk about is the pictures I've been using for posts. Anyone who has been visiting my site regularly will have noticed the old-timey photos I've been using. These are all from <a href="http://www.flickr.com/commons" target="_blank">The Commons</a>, a repository of public realm photography housed on <a href="http://www.flickr.com/" target="_blank">flickr</a>. It's tons of fun to peruse if you've got a bit of time to kill. All sorts of interesting archival photography. I like switching between looking up photos of famous events in history and thinking up more obscure searches to see what comes up.</p>
<p><span id="more-376"></span></p>
<p>In other news, I'm nearing 100,000 track plays on <a href="http://last.fm" target="_blank">last.fm</a>. There's a link to my account in the right column. I've been on last.fm for years, and it's pretty fascinating to look back through what I've listened to. All sorts of different kinds of music. Plenty of new artists I've discovered because of last.fm's recommendation engine.</p>
<p>On the videogame front I haven't been up to much. My grand idea to become a Master ranked 1v1 StarCraft 2 player hasn't really gone anywhere. I just can't really bring myself to commit the time and effort to go after it. I haven't even gotten myself reranked for season 2 in any bracket. SC2 isn't going anywhere though, so I could certainly get back into it this summer. <a href="http://www.teamfortress.com/freetoplay/" target="_blank">Team Fortress 2</a> going free to play makes me want to install it again and see if Emily might play a bit too. It would be fun to play an FPS together, but it's not really one of her preferred genres. I got through some more campaigns of Shogun 2 at least, which was fun. Keep meaning to play some Shogun 2 multiplayer.</p>
<p>With my now unlimited bandwidth (through <a href="http://www.distributel.ca/" target="_blank">Distributel</a>) I've been catching up on various shows through Netflix and other online sources. I'm on a pretty tight budget for the next while to pay off my credit cards, so not really in a position to be going out to pubs, other events, buy new videogames and so on. At least this should afford me plenty of time soon enough to push through the last half of my PHP book, get a bunch more posts up, and keep improving the site.</p>
<p>I suppose that's it for now. Can't think of anything else I'd like to say. The next PHP post is partially written, and I expect to finish it off this weekend, so stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/general-posts/quick-update-general/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning PHP &#8211; Part 2: The Basics</title>
		<link>http://michaelramsey.ca/web-dev/php/learning-php-part-2-basics/</link>
		<comments>http://michaelramsey.ca/web-dev/php/learning-php-part-2-basics/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 16:30:29 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[commenting]]></category>
		<category><![CDATA[intro]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[PHP Basics]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=334</guid>
		<description><![CDATA[A papier-mache cow on Mrs Mellor’s car, 1944 (from The Commons) Jumping into PHP hasn't been too hard for me. The book is aimed at people with a bit of programming/scripting experience, or at least a familiarity with the concepts. That worked just fine for me, since I have previously worked with VB a bunch [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;"><a href="http://michaelramsey.ca/web-dev/php/learning-php-part-2-basics/"><img src="/wp-content/uploads/paper-mache-cow-on-car.jpg" alt="" title="paper-mache-cow-on-car" width="500" height="355" class="aligncenter size-full wp-image-337" /></a></p>
<p style="text-align:center;margin-top:0;"><a href="http://www.flickr.com/photos/australian-war-memorial/3527160566/" target="_blank">A papier-mache cow on Mrs Mellor’s car</a>, 1944 (from The Commons)</p>
<p>Jumping into PHP hasn't been too hard for me. The book is aimed at people with a bit of programming/scripting experience, or at least a familiarity with the concepts. That worked just fine for me, since I have previously worked with VB a bunch when I was a teenager, and have had to hack bits of code here and there in the intervening years. So, the basics are more about learning the syntax and what sort of things you can and can't do.</p>
<p><span id="more-334"></span></p>
<h2>Basic Syntax</h2>
<p>To use PHP in a document, you must enclose it in PHP tags. To open a section of PHP code you use <b>&lt;?php</b>, and once you've finished you close the section with <b>?&gt;</b>. You can omit the "php" part of the opening tag, but this is informal and it's not like adding three letters is that time sink.</p>
<p>The first exercise is, like with pretty much every tutorial I've ever done, to print "<i>Hello World!</i>." To print something to the browser's screen (or more accurately, the source code of the page), you use the function "<b>echo()</b>" (or "<strong>print()</strong>"). Obviously just printing some text to the screen is a bit pointless when you can just do it with HTML, but you have to start somewhere. So, this code, placed in the &lt;body&gt; of an HTML page will print "Hello world!":</p>
<p style="margin-left:3em;"><b>&lt;?php<br />
echo 'Hello world!';<br />
?&gt;</b></p>
<p>The <b>echo()</b> function is just one of many that are built into PHP. You can also define your own functions, which I'll get to in a later post. As in the book, I'll continue to refer to functions with parenthesis at the end, even though not all functions actually use them. Keep in mind that the example above doesn't add any HTML. If you wanted to include paragraph or header tags for instance, you would have to place them within the single quotes in the echo function. Also worth noting now is that if you simply open the HTML file with this code in it using your web browser, the code will not run. Since PHP is a server-side scripting language, it MUST be placed on a server with PHP running on it. Then, when the file is requested, the server runs the PHP scripts and sends the output. </p>
<p>The next important concept is that PHP is usually white space insensitive. This is true of many languages, allowing you to space out your code in a way that makes it easy to work with, without any impact on the functionality. For instance, breaking an <b>echo()</b> statement over multiple lines will not change the output. What signifies the end of the statement is the semicolon.</p>
<p>If you want to add formatting for when the page is actually viewed in a browser, you must add the appropriate HTML. You can also add line breaks and tabs to the outputted code using <b>\t</b> for a tab and <b>\n</b> for a line break. Properly formatted HTML output will make debugging easier, so it's best not to ignore this aspect.</p>
<p>It's also important to comment your code for easier editing and debugging. Again, like HTML and various programming languages, PHP allows you to add comments. There are three ways to add comments (the last you'll probably recognize as being the same as in CSS):</p>
<p style="margin-left:3em;"><b># Comment text</b></p>
<p style="margin-left:3em;"><b>// Comment text</b></p>
<p style="margin-left:3em;"><b>/* Multi-line<br />
comment text */</b></p>
<p>Finally, it's important to note that you can enclose the data to be printed (and in other situations) with either single or double quotes. The important distinction is that variables and other PHP code within single quotes WILL NOT be run. Single quoted data indicated to the PHP engine to not look for any code within to run. If you want to include variables or other code within some data, use double quotes.</p>
<p>If you want to include single quotes in a single quoted string, you would run into the issue that it would close the string too early. Similarly, with if you have some elements of a double quoted string that would be interpreted as code, but isn't supposed to be, you'd run into the same issue. To use these characters you must escape them by placing a slash in front ("<b>\</b>").</p>
<p style="margin-left:3em;">For example:</p>
<p style="margin-left:3em;"><b>echo 'Michael\'s Blog'</b></p>
<p>I'll talk more about escaping problematic characters later on, as the characters that must be escaped change under different circumstances.</p>
<hr />
<p><i>Well, I've run out of time for this post. Been working on it during my lunch break. I think this is a reasonable place to leave it. Next time I'll continue with the rest of the basic stuff I learned in the introduction section of Larry Ullman's </i>PHP and MySQL for Dynamic Web Sites<i>. I'm planning to move this blog to <a href="http://michaelramsey.ca">michaelramsey.ca</a>, and then setup mokembo.com as a feed of both my posts and Emily's posts from <a href="http://emilyramsey.com">emilyramsey.com</a>. Then we'll also write some posts together exclusively for mokembo.com so that it has some original content still.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/php/learning-php-part-2-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning PHP &#8211; Part 1: Getting Started</title>
		<link>http://michaelramsey.ca/web-dev/php/learning-php-part-1-started/</link>
		<comments>http://michaelramsey.ca/web-dev/php/learning-php-part-1-started/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 22:15:58 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[intro]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[PHP Basics]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=285</guid>
		<description><![CDATA[An Egyptian Bazaar (from The Commons) Having finished off my HTML and CSS review and learning, I had a hard time deciding where to go next. Having already learned some JavaScript previously, I poked around in the W3schools tutorials for it, but ended up deciding to tackle PHP and MySQL. Part of the reason I [...]]]></description>
			<content:encoded><![CDATA[<p class="aligncenter" style="margin-bottom:0"><a href="http://mokembo.com/general-posts/learning-php-part-1-started/"><img src="http://mokembo.com/wp-content/uploads/2011/05/egypt-bazaar-the-commons.jpg" alt="Egypt: Arabic Window and Native Bazaar, Cair" title="egypt-bazaar-the-commons" width="500" height="471" class="aligncenter size-full wp-image-286" /></a></p>
<p class="aligncenter" style="margin-top:0px">An <a href="http://www.flickr.com/photos/brooklyn_museum/2674983932/" target="_blank">Egyptian Bazaar</a> (from The Commons)</p>
<p>Having finished off my HTML and CSS review and learning, I had a hard time deciding where to go next. Having already learned some JavaScript previously, I poked around in the W3schools tutorials for it, but ended up deciding to tackle PHP and MySQL.</p>
<p>Part of the reason I decided on PHP and MySQL is because I've had a book on the two technologies sitting around for some time. So I've been working my way through <i><a href="http://www.larryullman.com/books/php-and-mysql-for-dynamic-web-sites-visual-quickpro-guide-2nd-edition/" target="_blank">PHP and MySQL for Dynamic Web Sites</a></i> (2<sup>nd</sup> Edition) by <a href="http://www.larryullman.com/" target="_blank">Larry Ullman</a>. So far, in my humble opinion, it's an excellent book. I'm finding it is getting through the material at a good pace. The progression is quite logical from one chapter to the next, and the examples are quite relevant and useful. Since the book has been sitting around for awhile, it covers PHP 5 (which is now at version 5.3.6 a.k.a. PHP 6) and MySQL 4.1 (now at version 5.5). Obviously this makes it a bit out of date, but as far as I understand, the versions that I'm looking at are both still widely used, and the newer versions aren't a whole lot different.</p>
<p>Before jumping into the actual work I've done in learning PHP and MySQL, I figure I should give a bit of an introduction to what exactly PHP and MySQL are and what you do with them. The book also does this, which wasn't exactly that useful for me since I've got a fairly good undstanding of many web technologies, even if I don't know the details of how to actually use them.</p>
<p><span id="more-285"></span></p>
<h2>What is PHP?</h2>
<p><a href="http://php.net/" target="_blank">PHP</a> originally stood for "Personal Home Page" and was made by a fellow named Rasmus Lerdorf in 1994 to track visitors to his online resume. It's since gone through various revisions and has grown to become one of the top server-side scripting technologies, and now stands for "PHP: Hypertext Preprocessor". The fact that it's both free and easy to learn has made it a prime competitor for other server-side scripting tech like Microsoft's ASP. If you'd like to learn more, take a look at the <a href="http://en.wikipedia.org/wiki/PHP" target="_blank">article on PHP from Wikipedia</a>.</p>
<p>A "server-side scripting language" is one whose code is run on the server before serving up a page to the client. This is quite the opposite of client-side scripting languages, JavaScript being the most obvious example. JavaScript code, while similar, is served to the client as part of the page, and the client itself will run the script(s) on a page as needed. For PHP to work however, you must have the PHP engine installed on the web server, as PHP is not meant to be sent to the client like JavaScript.</p>
<p style="margin-left:3em;"><strong>Here's a run through of what happens when loading a PHP page:</strong><br />
<em>Client requests page from server<br />
Server finds file, sees it has PHP to be run, passes to PHP engine<br />
PHP engine runs code, creates page to be delivered to user<br />
Server sends completed page to user to view</em></p>
<p style="margin-left:3em;"><strong>JavaScript on the other hand, works rather differently:</strong><br />
<em>Client requests page from server<br />
Server sends page to client<br />
Client reads JavaScript, executing it on load or when the page is interacted with (depending on the nature of the script)</em></p>
<p>The above is obviously a simplification, but demostrates the general idea. While there is some overlap between what you can do with PHP and JavaScript respectively, the client/server distinction makes the two useful for rather different tasks. Beyond this, the two work extremely well together. For instance, I've been learning about setting up form validation (making sure that all fields are filled out and contain correct data in a form on a web page). While this can be done with PHP, because of it's server-side nature, it requires submitting the form to the server, and reloading the page if the validation fails. From a user's perspective, this can be slow and inconvenient. JavaScript is more than capable of doing form validation on the client's side, allowing it to happen immediately and not have to needlessly use up bandwidth and the server's resources.</p>
<p>PHP allows you to set up dynamic websites, where how a page is displayed can be altered based on user input among other factors. It allows basically static parts of the site (like the header and footer) be set in one place and called by every page on the site, greatly simplifying making changes that would otherwise have to be repeated for each page. It also has the ability to interface with a database (this is where MySQL comes in), allowing even greater automation, particularly of content management. Many popular Content Management Systems (CMS) like <a href="http://wordpress.org/" target="_blank">WordPress</a>, <a href="http://www.joomla.org/" target="_blank">Joomla</a> and <a href="http://drupal.org/" target="_blank">Drupal</a> are built using PHP.</p>
<h2>What is MySQL?</h3>
<p><a href="http://www.mysql.com/" target="_blank">MySQL</a> is an open-source database system. It's available at little to no cost, and offers features on par with much more expensive database software. <a href="http://en.wikipedia.org/wiki/SQL" target="_blank">SQL</a> stands for Structured Query Language, and was invented in the 1970s for the Relational Data Base Management Systems (RDBMS) as laid out by Edgar F. Codd's relational model. These RDBMS use multiple tables to store various sets of data and use various methods to build a web of interrelations between the tables. The system is much more effective than a simple flat file database (basically, a spreadsheet) and offers a range of features unavailable in simpler DBs.</p>
<p>MySQL is one particular SQL based database system. Since I'm going to be covering how to work with MySQL and will have an intro post for it as well, I'll leave this part quite short. In relation to PHP though, it's important to note that PHP has a whole variety of functions that deal with storing and retrieving data from MySQL databases specifically. Going back to the example of the process by which a PHP page is retreived; if the PHP on the page is required to insert or read data from a MySQL database it does so at the same time as the server runs the PHP code.</p>
<hr />
<p><i>I think that about covers what I wanted to touch on with this introduction. I'm looking forward to actually getting into the stuff I've been learning. I'm already almost half way through the book, so lots to cover. I've been spending more time working on the stuff than I have been updating the blog. I'm sure I'll push through and end up with a backlog of posts queued to go up though. In other news, I haven't been following through with my plan to get seriously back into Starcraft 2. Too many other things going on lately, but I did play a bunch of Shogun 2 again on the weekend.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/php/learning-php-part-1-started/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learning CSS &#8211; Part 8: Image Sprites and Media Types</title>
		<link>http://michaelramsey.ca/web-dev/css/learning-css-part-8-image-sprites-media-types/</link>
		<comments>http://michaelramsey.ca/web-dev/css/learning-css-part-8-image-sprites-media-types/#comments</comments>
		<pubDate>Wed, 25 May 2011 18:10:45 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[image sprites]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[media types]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=249</guid>
		<description><![CDATA[Coolie on a road in Java, 1946 (from The Commons) Glad to be doing this last CSS post. Like I've said before, I'm sure I'll be revisiting CSS after this, but not in an organized, step by step way. I've been through a good assortment of the basic stuff that can be done with CSS [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;margin-bottom:0"><a href="http://mokembo.com/web-dev/css/learning-css-part-8-image-sprites-media-types/"><img src="http://mokembo.com/wp-content/uploads/2011/05/coolie-on-road-in-java.jpg" alt="Coolie on a road in Java" title="coolie-on-road-in-java" width="500" height="500" class="alignnone size-full wp-image-272" /></a></p>
<p style="text-align:center;margin-top:2px"><a href="http://www.flickr.com/photos/nationaalarchief/4600341341/" target="_blank">Coolie on a road in Java, 1946</a> (from The Commons)</p>
<p>Glad to be doing this last CSS post. Like I've said before, I'm sure I'll be revisiting CSS after this, but not in an organized, step by step way. I've been through a good assortment of the basic stuff that can be done with CSS as well as a few more interesting aspects (like Sprites, coming up). There are all sorts of fancy CSS tricks, particularly with the new stuff in CSS3. Those are the kinds of things I'm looking forward to talking about in the future. For example, I read a neat post about advanced shapes you can make with CSS3 (I can't seem to find the link though).</p>
<h2>Image Sprites</h2>
<p>Back in the days before everyone was on broadband, you had to be super careful to keep your pages' file sizes small. Too many images and/or too long a page and the many users on 33.6-56k modems would be forced to sit through minutes of loading for every page. The issue still exists today, but it's now more of an advanced usability, SEO and high volume website concern.</p>
<p>When a page is loaded, the first aspect to be retrieved is the page's source code itself. In the source of the average webpage are calls to various external files such as JavaScript scripts, CSS files, and images. Each of these requires its own call to the server to download that file before the page can be displayed (generally at least, but not always). When you've got a handful of different external scripts, CSS files and a whole bunch of images to load, you're faced with quite a few separate requests to be made. These requests account for a significant portion of the load time for a page.<span id="more-249"></span></p>
<p>Using CSS Sprites is the solution to the image part of this problem. Often you will use the exact same set of images on many, or even of the pages on a site. Between a banner, navigation, logos and things like that could all be images. What CSS Sprites allows you to do is combine these repeatedly used images into one large image. The client then only has to download one image, and using CSS you can tell only small portions of the image to be displayed in a certain place. You can also use this for creating hover effects as well - calling one part of the image for normal display, and another when moused over. Unlike the old way of doing hover effects with HTML alone, there is no delay to load the new image when hovering.</p>
<p>In the <a href="http://www.w3schools.com/css/css_image_sprites.asp" target="_blank">w3schools CSS Sprite examples</a> they use a series of IDs to specify a part of the one image as the background to whatever element the ID is applied to. Here's an example (click through above to see all their examples and ht helpful "Try it yourself" pages):</p>
<p style="text-indent:20px;"><b>#next a:hover{background: url('img_navsprites_hover.gif') -91px -45px;}</b></p>
<p>As you can see, after the image's file name a set of pixel coordinates are listed for how far from the top left corner of the full image to start for the sprite. The first number is the horizontal coordinate, and the second number the vertical. How much of the image is shown is controlled by setting the height and width of the element that contains the image.</p>
<h2>Media Types</h2>
<p>I was going to talk about media types, but there isn't really a lot to say. The important thing is that you can set a series of special CSS settings for how a page will look when printed separately from how it will look when on screen. To do this you preface the CSS code with "<b>@media print</b>" to apply the subsequent settings to print, "<b>@media handheld</b>" for small devices, or "<b>@media screen</b>" to make sure that styles are only for screen. There are a variety of other media types, but this is largely for accessibility concerns. Take a look at the <a href="http://www.w3schools.com/css/css_mediatypes.asp" target="_blank">w3schools page about media types</a> for more info.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/css/learning-css-part-8-image-sprites-media-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning CSS &#8211; Part 7: Navigation Bar and Image Opacity</title>
		<link>http://michaelramsey.ca/web-dev/css/learning-css-part-7-wrapping/</link>
		<comments>http://michaelramsey.ca/web-dev/css/learning-css-part-7-wrapping/#comments</comments>
		<pubDate>Fri, 20 May 2011 16:00:18 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[learning]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=218</guid>
		<description><![CDATA[Katoomba Falls (from The Commons) I'm coming to the end of what was covered in the w3schools CSS Tutorial. As I mentioned in the last post about learning CSS, there are only a few more things I'd like to cover. In this post I'm going to cover the navigation bar example and image opacity parts [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;margin-bottom:0"><a href="http://mokembo.com/web-dev/css/learning-css-part-7-wrapping/"><img src="http://mokembo.com/wp-content/uploads/2011/05/katoomba-falls-cascade.jpg" alt="Katoomba Falls Cascade" title="katoomba-falls-cascade" width="386" height="500" class="alignnone size-full wp-image-222" /></a></p>
<p style="text-align:center;margin-top:2px"><a href="http://www.flickr.com/photos/powerhouse_museum/4903259629/" target="_blank">Katoomba Falls</a> (from The Commons)</p>
<p>I'm coming to the end of what was covered in the w3schools <a href="http://www.w3schools.com/css/css_intro.asp" target="_blank">CSS Tutorial</a>. As I mentioned in the <a href="http://mokembo.com/web-dev/css/learning-css-part-6-moving-basics/">last post about learning CSS</a>, there are only a few more things I'd like to cover. In this post I'm going to cover the navigation bar example and image opacity parts of CSS Advanced.</p>
<h2>CSS Navigation Bar Example</h2>
<p>The <a href="http://www.w3schools.com/css/css_navbar.asp" target="_blank">CSS navigation bar</a> example is a great way to show how CSS allows you to create quite visually appealing designs without the use of images. By combining a variety of different basic techniques that have previously been covered, quite a nice looking navigation bar is created. Instead of recreating it here, head over to the page using the link above and take a look for yourself.<span id="more-218"></span></p>
<p>The horizontal navigation bar is set up as a basic unordered list:</p>
<p style="margin-left:3em;font-weight:bold;">&lt;ul&gt;<br />
&lt;li&gt;&lt;a href=&quot;default.asp&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&quot;news.asp&quot;&gt;News&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&quot;contact.asp&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&quot;about.asp&quot;&gt;About&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;</p>
<p>To turn this simple list into a horizontal navigation bar, first the list items need to be set to float left (alternately, they could be set to "inline" for almost the same effect). The unordered list is set to have no padding or margin, overflow is hidden and the list-style-type is set to none (to supress the bullet points). </p>
<p>The links (anchor tags) are then styled to create the right look. They're set to display as a block, given a set width, and have their text and background colours set along with some changes to center the text, add a bit of padding and remove the underline. These styles are applied to "a:link" and "a:visited", and the alternate background colour is the only setting applied to "a:hover" and "a:active" (since they otherwise inherit the "a:link" settings).</p>
<h2>Image Opacity</h2>
<p>Part of CSS3, and not part of the regular CSS standard yet, opacity is fairly widely supported, and can be used to make images or other elements transparent. By using "opacity:x" (where x is between 0 and 1) you can set how transparent you want something to be. 0 is completely transparent, while 1 is completely opaque. This will work for most browsers, but for IE you have to use "filter:alpha(opacity=x)" instead. To make sure your opacity settings are seen in all browsers, you'll have to use both.</p>
<p>A neat trick that w3schools points out is using transparancy with onmouseover events. You could make an image gallery where the focused image is fully opaque and others fade out for instance.</p>
<p>In the <a href="http://www.w3schools.com/css/css_image_transparency.asp" target="_blank">CSS Image Opacity</a> tutorial there is also a neat semi-transparent text box created with divs. This is an effect I could certainly see myself using at some point.</p>
<p><i>The next post will be the last of the Learning CSS series! After that, I'll be onto JavaScript and PHP. Of course, there is more to CSS beyond what I've covered. I'll certainly be returning to it, but to look at particular aspects instead of progressing through a set path like I have been so far.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/css/learning-css-part-7-wrapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning CSS – Part 6: Moving Past the Basics</title>
		<link>http://michaelramsey.ca/web-dev/css/learning-css-part-6-moving-basics/</link>
		<comments>http://michaelramsey.ca/web-dev/css/learning-css-part-6-moving-basics/#comments</comments>
		<pubDate>Wed, 18 May 2011 18:20:40 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[learning]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=201</guid>
		<description><![CDATA[Possum Camera! (from The Commons) The "CSS Advanced" section of the w3schools moves on to a less structured format. It covers a variety of different concepts. Some of these I thought more interesting than others. I'm going to touch on a variety of points that I found useful, but not go through all of it [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;margin-bottom:0"><a href="http://mokembo.com/web-dev/css/learning-css-part-6-moving-basics/"><img src="http://mokembo.com/wp-content/uploads/2011/05/camera-possum.jpg" alt="possum camera man" title="camera-possum" width="500" height="369" class="size-full wp-image-202" /></a></p>
<p style="text-align:center;margin-top:2px"><a href="http://www.flickr.com/photos/australian-war-memorial/3527157206/" target="_blank">Possum Camera</a>! (from The Commons)</p>
<p>The "<a href="http://www.w3schools.com/css/css_grouping_nesting.asp" target="_blank">CSS Advanced</a>" section of the w3schools moves on to a less structured format. It covers a variety of different concepts. Some of these I thought more interesting than others. I'm going to touch on a variety of points that I found useful, but not go through all of it in detail.</p>
<h2>Grouping and Nesting</h2>
<p>Grouping and Nesting are pretty important. It's quite likely that in a set of styles for a site, you will want to set the same settings for a variety of different selectors (tags). By adding multiple selectors separated by commas, you can apply the subsequent styles to all of the selectors.<span id="more-201"></span></p>
<p>Kind of the opposite idea to the above, if you place a selector after stating a class, than the following styles will only apply to those tags with that class as well. If the class is specified for another tag, the styles won't apply, and the same goes for the same tags which don't have the class applied. (For examples of both of these, the link above to CSS Advanced takes you to the Grouping/Nesting page.)</p>
<h2>Block and Inline</h2>
<p>Another useful setting you can change is whether an element is "block" or "inline" (the former have breaks before and after, like a paragraph or list item, while the latter do not cause line breaks, like &lt;span&gt;). By changing this you can create a horizontal list (great for navigation). I'm not really sure why you would want to make an inline element change to block, but there's probably a good reason I'm not thinking of. The code for this is really easy: "display:block" and "display:inline" respectively.</p>
<h2>Positioning</h2>
<p>There's a few interesting things you can do with <a href="http://www.w3schools.com/css/css_positioning.asp" target="_blank">CSS Positioning</a>. By default HTML elements use static positioning. The other options are Fixed, Absolute and Relative positioning. These are just what they sound like; fixed position elements will stay in place in the browser even while scrolling, than absolute positioning will keep an element positioning in a certain place relative to the element it is within. (You'd likely want to use these two together, fix one thing, than relatively position other elements within it - like a CTA for signing up to email updates, or buying your prize winning green widgets.) Relative positioning will move an element relative to its position without any special changes.</p>
<p>Another super useful positioning setting is the ability to set how elements overlap. You do this by setting a "z-index" for each element. Elements with a higher z-index number will be positioned overtop of those with lower z-index numbers (default being zero). Also, you can use positive or negative numbers.</p>
<p>You can also "float" elements. This is generally used for images. If you want an image to allow text to flow around it you can tell it to float on the left or right. This is great for inserting small images next to text.</p>
<p><i>Next time I'll wrap this up with a fancy CSS navigation bar example, image opacity, image sprites and media types (among a few other things possibly). I've been getting started with JavaScript and will be also starting my PHP + MySQL book after I finish off the novel I'm currently reading. In other news, getting back into <a href="http://us.battle.net/sc2/en/" target="_blank">StarCraft 2</a> a bit and been playing a bunch of <a href="http://www.minecraft.net/" target="_blank">Minecraft</a> multiplayer.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/css/learning-css-part-6-moving-basics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learning CSS &#8211; Part 5: Box Model</title>
		<link>http://michaelramsey.ca/web-dev/css/learning-css-part-5-box-model/</link>
		<comments>http://michaelramsey.ca/web-dev/css/learning-css-part-5-box-model/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:10:32 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS Basics]]></category>
		<category><![CDATA[learning]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=187</guid>
		<description><![CDATA[Wombat or something on a bike with a girl (from The Commons) Understanding the CSS "Box Model" is quite important. As I mentioned in the previous Learning CSS post, webpages are generally built by using sets of nested table-like elements using &#60;div&#62; tags (replacing HTML tables for this purpose). Many different elements can make use [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:center; margin-bottom:0;"><a href="ttp://mokembo.com/web-dev/css/learning-css-part-5-box-model/"><img src="http://mokembo.com/wp-content/uploads/2011/04/weird-animal-on-a-bike.jpg" alt="animal on a bike with a girl" title="animal on a bike with a girl" width="475" height="640" class="alignnone size-full wp-image-188" /></a></p>
<p style="text-align:center; margin-top:2px;"><a href="http://www.flickr.com/photos/statelibraryofnsw/3257005706/" target="_blank">Wombat or something on a bike with a girl</a> (from The Commons)</p>
<p>Understanding the CSS "Box Model" is quite important. As I mentioned in the <a href="http://mokembo.com/web-dev/css/learning-css-part-4-basic-styling-continued/">previous Learning CSS post</a>, webpages are generally built by using sets of nested table-like elements using &lt;div&gt; tags (replacing HTML tables for this purpose). Many different elements can make use of the same box model settings. Margin, border and padding are the three main settings that are used to achieve just the right spacing in layouts.</p>
<p>The <a href="http://www.w3schools.com/css/css_boxmodel.asp" target="_blank">w3schools box model intro page</a> has a very helpful image that shows how margin, border and padding work. margin is the outermost area. Adjusting the margins changes the empty space around the border. The border is exactly that. You can adjust the size and visibility of the border, as well as apply various outline styles to appear around the border edge (among other things). Finally, the padding is the empty space within the confines of the border, spacing out the actual content from the border itself.</p>
<p><span id="more-187"></span></p>
<p>What is important to know is that when you adjust the width and height of an element, you are setting it for the content area. You must ad the width/height of the margin, padding and border to this to get the full size of the element. (However, unless you declare a DOCTYPE, the preceding is not true for IE8 an earlier. Instead, the width value will include padding and border. So, make sure you declare a DOCTYPE.)</p>
<p>There are a bunch of different outline options that I could go over. However, I see them as a bit of a gimmick and not something I'm likely to ever use. If you're really interested there are a bunch of examples you can work with over on the <a href="http://www.w3schools.com/css/css_outline.asp" target="_blank">w3schools page about CSS Outlines</a>.</p>
<p>As usual, you can define margin, border and padding size by a variety of possible units recognized in CSS. You should probably use pixels ("px") unless you have some fancy resizing stuff going on. You can set top, bottom, left and right size values for each aspect. There is a useful shorthand to cut down on how the size of your CSS. Instead of having to declare margin-bottom, margin-top, margin-right, margin-left individually, you can use a single line. Here are the examples demonstrating this (taken from <a href="http://www.w3schools.com/css/css_margin.asp" target="_blank">w3schools</a>):</p>
<ul>
<li><b>margin:25px 50px 75px 100px; </b>
<ul>
<li>top margin is 25px</li>
<li>right margin is 50px</li>
<li>bottom margin is 75px</li>
<li>left margin is 100px</li>
</ul>
<p>
	</li>
<li><b>margin:25px 50px 75px;</b>
<ul>
<li>top margin is 25px</li>
<li>right and left margins are 50px</li>
<li>bottom margin is 75px</li>
</ul>
<p>
    </li>
<li><b>margin:25px 50px;</b>
<ul>
<li>top and bottom margins are 25px</li>
<li>right and left margins are 50px</li>
</ul>
<p>
	</li>
<li><b>margin:25px;</b>
<ul>
<li>all four margins are 25px</li>
</ul>
</li>
</ul>
<p>So there are a variety of options depending on which sides you need to set differently from one another. The shorthand for padding works exactly the same way.</p>
<p><i><b>P.S.</b> Haven't been getting posts up as often as I'd like. Feels like it's taking awhile to get through the CSS stuff even though I've long since finished my review. Maybe I'll jump into some PHP stuff at the same time and switch back and forth. Otherwise, been keeping busy reading a bunch of novels (finished off the main <a href="http://en.wikipedia.org/wiki/Dune_universe" target="_blank">Dune series</a> and most of the way through a <a href="http://en.wikipedia.org/wiki/South_of_the_Border,_West_of_the_Sun" target="_blank">Haruki Murakami book I hadn't read before</a>) and played through <a href="www.thinkwithportals.com" target="_blank">Portal 2</a> single player and coop (which only took about a week, but was tons of fun). Been letting <a href="www.riftgame.com" target="_blank">Rift</a> and <a href="www.totalwar.com/shogun2" target="_blank">Shogun 2</a> fall to the wayside.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/css/learning-css-part-5-box-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning CSS &#8211; Part 4: Basic Styling continued</title>
		<link>http://michaelramsey.ca/web-dev/css/learning-css-part-4-basic-styling-continued/</link>
		<comments>http://michaelramsey.ca/web-dev/css/learning-css-part-4-basic-styling-continued/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 23:45:37 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS Basics]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=172</guid>
		<description><![CDATA[Election Night 1931 in Wellington, NZ (from The Commons) Jumping back in where I left off in the last Learning CSS post, I still need to cover the basic styling options for links, lists and tables. At this point what I'm covering is still quite simple to learn and is partially review for me. Links [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;text-align:center;"><a href="http://mokembo.com/web-dev/css/learning-css-part-4-basic-styling-continued/"><img src="http://mokembo.com/wp-content/uploads/2011/04/election-night-1931.jpg" alt="Election Night 1931 in Wellington NZ" title="Election Night 1931 in Wellington NZ" width="500" height="350" class="alignnone size-full wp-image-175" /></a></p>
<p style="margin-top:2px;text-align:center;"><a href="http://www.flickr.com/photos/nationallibrarynz_commons/3326203787/" target="_blank">Election Night 1931 in Wellington, NZ</a> (from The Commons)</p>
<p>Jumping back in where I left off in the last <a href="http://mokembo.com/web-dev/css/learning-css-part-3-basic-styling/">Learning CSS post</a>, I still need to cover the basic styling options for links, lists and tables. At this point what I'm covering is still quite simple to learn and is partially review for me.</p>
<h2>Links</h2>
<p>The basic styling you can do for links using CSS is to change the link colour, visited colour, hover colour and active colour. Traditional website usability wisdom said that you should never change the colour of links because the majority of users relied on the colour as an indicator of what is clickable. To the delight of usability concious website designers everwhere, this is no longer the case. Today you can get away with using pretty much any colour for links, provided it stands out in contrast to the other colours used in your overall site design.</p>
<p><span id="more-172"></span></p>
<p>On the other hand, underlining has taken over as the primary indicator for spotting links on a page. So go ahead and change link colours, but keep them underlined, and use underlining for other elements knowing full well you risk frustrating users who will try to click the underlined non-linked text. Of course the standard blue is still the most usable choice if you want to make your site as easy to use as possible.</p>
<p>Customizing links is pretty straighforward. You could apply text-decoration settings as well as colour attributes. There is also a specific order to how these are declared or it may not work. Here's the example from w3schools:</p>
<p style="margin-left:2em;"><b>a:link {color:#FF0000;}      /* unvisited link */<br />a:visited {color:#00FF00;}  /* visited link */<br />a:hover {color:#FF00FF;}  /* mouse over link */<br />a:active {color:#0000FF;}  /* selected link */</b></p>
<p>I don't think I mentioned in an earlier post, but "/* */" is how you indicate comments in CSS (like &lt;!-- --&gt; with HTML). Otherwise, the link styling is quite simple.</p>
<h2>Lists</h2>
<p>Lists work with many of the same settings you can use for paragraphs, headers and other ordinary elements. The list specific styling options that CSS gives you are for changing the bullets (for unordered lists) or numbers (for ordered lists). There's a nice table of the various options over on the <a href="http://www.w3schools.com/css/css_list.asp" target="_blank">w3schools list basics page</a>. The important thing to know is that some of the styles may not work on earlier versions of some browsers (particularly IE). As long as you declare a DOCTYPE though, they should.</p>
<p>You can also choose an image to use as a bullet point using "<b>list-style-image: url('image.gif');</b>" but there are various issues with the position of this image being set slightly differently from one browser to another. The w3school pages linked above has a fix for this where you manually set the margins for the image bullet, forcing it to display the same way across various browsers.</p>
<h2>Tables</h2>
<p>Tables were what separated competent web design from novice web design back in the day. You could create a much slicker looking page layout be using an invisible table to carefully position various parts of the page. Obviously today there are few popular sites/pages that aren't structured using a table-like page setup, usually using &lt;div&gt; tags.</p>
<p>There are all sorts of settings you can change for tables, many of which were also in HTML back when I learned it. Of course with traditional HTML table styling it could be a huge amount of work if you wanted to make a nice looking table. CSS lets you set up your styles and call them as needed (like with everything else in CSS).</p>
<p>Some of the most important settings you can change have to do with the CSS box model, where you control the margin, border and padding. This applies to many elements and will be the subject of my next post. Understanding the box model is a very important part of knowing how to work with CSS (from my point of view so far at least).</p>
<p>Beyond that, you can set the height and width of tables as well as rows, columns and cells individually. Horizontal and vertical alignment can be set, much like you would in Excel. Background, text and border colour have their own settings too. Theres a very nice <a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_table_fancy" target="_blank">Fancy Table Example</a> over on w3schools that you can play around with. The alternating row colour looks great in my humble opinion, while the collapsed table borders come in a close second for favourite basic style customization.</p>
<p>Next time I'll continue my coverage of working through CSS tutorials by going over the "Box Model" &#8212; an extremely useful bit of CSS to understand, and one that is used constantly when working on website layouts.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/css/learning-css-part-4-basic-styling-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning CSS &#8211; Part 3: Basic Styling</title>
		<link>http://michaelramsey.ca/web-dev/css/learning-css-part-3-basic-styling/</link>
		<comments>http://michaelramsey.ca/web-dev/css/learning-css-part-3-basic-styling/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 16:42:11 +0000</pubDate>
		<dc:creator>Moketronics</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS Basics]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://mokembo.com/?p=147</guid>
		<description><![CDATA[Swedes in Hats (from The Commons) My continued forays into the world of CSS had me learning an array of basic styling options. As mentioned in an earlier post, many of these style options were previously done with HTML. CSS took over these functions and provides a much wider array of options and removed the [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom:0;text-align:center;"><a href="http://mokembo.com/web-dev/css/learning-css-part-3-basic-styling/"><img src="http://mokembo.com/wp-content/uploads/2011/04/swedes-in-hats.jpg" alt="Swedes in Hats (from The Commons)" title="Swedes in Hats (from The Commons)" width="500" height="289" class="alignnone size-full wp-image-148" /></a></p>
<p style="margin-top:2px;text-align:center;"><a href="http://www.flickr.com/photos/swedish_heritage_board/3512261887/" target="_blank">Swedes in Hats</a> (from The Commons)</p>
<p>My continued forays into the world of CSS had me learning an array of basic styling options. As mentioned in an earlier post, many of these style options were previously done with HTML. CSS took over these functions and provides a much wider array of options and removed the need to setup styles individually for every instance.</p>
<p>The W3 Schools tutorial covers 6 elements in the basic styling overview: <a href="http://www.w3schools.com/css/css_background.asp" target="_blank">Backgrounds</a>, <a href="http://www.w3schools.com/css/css_text.asp" target="_blank">Text</a>, <a href="http://www.w3schools.com/css/css_font.asp" target="_blank">Fonts</a>, <a href="http://www.w3schools.com/css/css_link.asp" target="_blank">Links</a>, <a href="http://www.w3schools.com/css/css_list.asp" target="_blank">Lists</a> and <a href="http://www.w3schools.com/css/css_table.asp" target="_blank">Tables</a>. Having had to deal with some aspects of site updates in previous years I ended up learning bits and pieces of the syntax for these, but never went over it in a methodical way. As would be expected, the basic styling is all pretty simple and doesn't take long to learn. With that in mind, I'm going to cover each aspect only briefly, with a little extra on a few interesting aspects added in.</p>
<p><span id="more-147"></span></p>
<h2>Backgrounds</h2>
<p>As with HTML before it, the standard option for a background of an element is either a colour or an image. Colours can be set using a named color value ("green"), a HEX value ("rgb(0,255,0)") or an RGB value ("#00FF00"). For a colour you would use "<strong>background-color:<i>VALUE</i>;</strong>", while if you want to use an image you would use "<strong>background-image:url('<em>filename.gif</em>')</strong>". The usual place you'll be setting a background colour or image is for your "body" (the full page), but many other elements can have their own background colour or image set as well. For instance different sections of a table, or a paragraph you want to draw attention to.</p>
<p>There are a couple neat things you can do with background images beyond simply choosing a colour or image. For instance, you can choose whether an image will repeat (tile) across the page, and if so, whether it tiles vertically, horizontally, or both. To do this use "<b>background-repeat:</b>", which can have the values: repeat, repeat-x, repeat-y or no-repeat. You've probably seen websites where the background doesn't scroll with the page, this can be set by using "<b>background-attachment:</b>", while "<b>background-position:</b>" will (obviously) set where the background image appears. You can set general areas like "left top," "center center" or "right bottom." The other option is to use x/y values to choose an exact position.</p>
<h2>Text</h2>
<p>A few of the most basic styles you can set for text were covered in my <a href="http://mokembo.com/web-dev/css/introduction-wondeful-world-css/">Introduction to CSS</a> post. The basic options allow you to set the colour, alignment, decoration (strikethrough, underline, etc.), size, indentation, direction, spacing, line-height among various other options. Plenty of full lists around of exactly what can be used and how, just take a look at the w3schools page linked to at the start of this post.</p>
<p>The one basic style they mention that I thought was interesting is "blink" &mdash; I thought this had been phased out but apparently it was ported into CSS. Adding &lt;blink&gt; tags was the hallmark of terrible 90's webdesign.</p>
<p style="font-family:Times, serif; color:lime; text-decoration:blink; background-color:yellow; text-align:center;"><strong>Just look at this example and cringe as this ugly text blinks at you! Very geocities.</strong></p>
<h2>Fonts</h2>
<p>Better control over fonts was a desperately needed in web design, and CSS did a lot to address the issues. Thanks to inconsistent font sets from one computer to another, choosing a font that wasn't among the most common used to mean that you were virtually guarenteed to have your page display incorrectly on other computers and browsers. CSS added the ability to choose specific fonts, then choose a certain font family as backup, and if that failed, at least maintain the general feel of the font you wanted by defaulting to serif or sans-serif fonts. (Don't know the difference? <a href="http://www.w3schools.com/css/css_font.asp" target="_blank">w3schools has a nice little graphic</a> that explains it.) Of course fonts can be set for specific elements like with other properties, allowing you to choose one set of fonts for headlines, another set for paragraphs and another for lists (as an example).</p>
<p>What I found interesting in particular was the recommendations for how you should set font size. I was familiar with some of the different units available (cm, px, em, %) as well as the more generic sizes (large, x-small, medium). What I learned was that "1em" is the current font size, and is usually equal to 16 pixels. However, different browsers handle the resizing of text in different ways leading to issues. To prevent this, it is best to set your default (body) font size by percent, then all other font sizes by em. This should work in all browsers even when the page is zoomed or text resized.</p>
<p>I'll wrap up the basics (Links, Lists and Tables) in the next post, since this post is getting fairly long. Also, I was away in California for the <a href="http://www.mequoda.com/" target="_blank">Mequoda</a> Summit West 2011 last week, which is why I didn't keep up my otherwise fairly active posting schedule so far. I'm planning to do a post about some of the interesting things I learned at the conference in the next few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelramsey.ca/web-dev/css/learning-css-part-3-basic-styling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
