The Awesome Trick of Absolute and Relative Positioning!

There’s an awesome trick when combining absolute and relative positioning in CSS. It works like this:

When a parent element’s position is relative, and a child element’s position is absolute, you can then set the top/left/right/bottom position of the child element, within the container of the parent.

Sample CSS:

.parent {

.son {
  position: absolute;
  top: 15px;
  left: 25px;


How to Set Body Background Color in JavaScript before page load.

I recently answered a question at StackOverflow about how to change the background color of the BODY element of a web page, before the page was loaded… using JavaScript.

Instead of relying on event handlers, I went with one of the earliest (and least used these days) methods in javascript:


Yes, document.write. It’s one of the earliest ways of rendering HTML onto a web page using JavaScript, and I had tons of fun with it when I was 14. Anyway, here’s the code…

<!doctype html>
      <title>Background Change</title>
      <meta charset="UTF-8">
      <style type="text/css">
      body {
           background-color: #FFFFFF;
           var color = "#000000";
                  document.write("<style type=\"text\/css\">" + 
                   "body{background-color: " + color + ";}</style>");

In the above example, we created an anonymous function, then simply wrote in a <style> tag with our changes to CSS.

That’s it!

Don’t forget, complexity can kill your chance of success.

Web Developers Aren’t Marketers – So Stop Asking!

I browse Upwork for freelance gigs, and one common project under ‘Web Development’ is to create a WordPress/Magento/Wix/Squarespace (you name it) website, that increases leads, sales, or search engine ranking through SEO.

The primary thinking is this: that developers can create a website that magically gets people to buy products, sign up for subscriptions, or send information to create a mailing list, without effort on the business owner.

My response is: If I, as a developer, knew how to do that, wouldn’t I do it for myself first, and then build an empire of cash generating websites? Of course I would!

The reality is that developers create tools; we don’t create businesses. Customers don’t give two shits about the tools you use to give them what they want. (Seriously, people in the U.S. still buy clothes made in sweatshops in starving nations.)

No amount of development will do the marketing and selling for you. If this were true, there’d be tons of people developing websites attempting to generate tons of money – but because there would be tons of websites that do the same thing, they, by numbers alone, would diminish their value. Thus, it wouldn’t last, and very quickly wouldn’t be an endeavor that makes sense to pursue (financially).

When seeking a developer to build a website, think of asking a person to create a tool for you (and your customers) to use to get what they way. It should be nothing more than that, nothing less. Want to post articles? Ask for a blog. Want to sell products? Ask for a shopping cart and payment processing.

But don’t ask a developer to build a website that will do the marketing and sales for you. It’s a black hole of hope in a topic that business owners just seem to (still) think is a way for them to reduce their marketing/sales budget to zero, and get massive popularity.

Again, if I knew how to do that as a developer — I would do it! And then I would share it with everyone, so everyone can benefit! I want to see businesses succeed!