How To Set A Maximum Width or Maximum Height For An Image With CSS


I was trying to figure out how to set the maximum width and maximum height for my images, and I wanted a way that didn’t require PHP programming. I finally found a way and stumbled upon how CSS could make use of expressions as well. It’s a method where you can have a conditional statement in CSS, as follows: #container img { max-width:500px; width: expression(this.width > 500 ? 500:...

Use Javascript to Display Random Image and Link


I was editing a PHP script today when I realised that one of the files did not allow PHP code. Weird. But the annoying thing was that I NEEDED it to run PHP code — or rather, I needed it to randomly display an image with a link. So I had to find other means, which turned out to be good ol’ Javascript. The code below will allow you to use Javascript to randomly output or show an image...

Formatting a Decimal Number to 2 Decimal Places in Java or JSP


I was looking around for the class to format a number to 2 decimal places while I was coding Java, or specifically JSP, and I found it. First, you need to import the DecimalFormat class, so have this line at the top of your Java file: import java.text.DecimalFormat; Or if you’re running JSP: And here’s the actual code that does the magic: double price = 10.59; DecimalFormat...

About Author

I've over 17 years of entrepreneurship experience, having built a tech company to be the top in the country, which was subsequently acquired for an 8-figure sum. As CEO, I led the company through robust growth to 150 employees across 4 countries. After the acquisition, I embraced minimalism, sold off my personal possessions, and started living around the world.

Read more about my story here.