Centering Images with CSS

img {
text-align: center;
}
That will not work as the text-align property applies to block containers, not inline elements, and img is an inline element.

Put text-align: center on a containing block and as long as the image is still inline, it will be centered.

If the image itself is set to block then it must have left and right margins set to auto.

 

Breaking down a function – updateRecords()

A friend asked me to explain this code in detail for a function called updateRecords() that they were studying on an online learning site. Actually they expect you to create the guts of the function yourself and make sure it meets certain requirements. This is my solution and explanation. It is designed for somewhat beginners so Its deliberately not succinct because the purpose is to explain whats going on in detail in a simple way that is easy to follow. At the end I will demonstrate alternative ways to write the same function in a more concise manner.

Continue reading “Breaking down a function – updateRecords()”

Reconciling Return

The return keyword and its purpose is actually fairly simple but for some reason it seems to cause beginners a lot of confusion. Even after being exposed to it by example and explanation, it can take some time before understanding really sinks in. I know this was certainly the case for me but I don’t believe it needed to be that way. Lets see if we can’t help lessen that confusion here.

Continue reading “Reconciling Return”

Basic Toggling with javascript

If your not familiar with natural javascript and your only used to using a library like jQuery, then you might be surprised to learn that javascript doesn’t have a predefined toggle function that you can just call up when you want. You need to create your own before you can use it. Here is a bare bones demonstration of toggling in plain old ordinary javascript.

Continue reading “Basic Toggling with javascript”