How to Create Printer-friendly Pages with CSS

In this article, we review the art of creating printer-friendly web pages with CSS.

“Who prints web pages?” I hear you cry! Relatively few pages will ever be reproduced on paper. But consider:

printing travel or concert tickets
reproducing route directions or timetables
saving a copy for offline reading
accessing information in an area with poor connectivity
using data in dangerous or dirty conditions — for example, a kitchen or factory
outputting draft content for written annotations
printing web receipts for bookkeeping purposes
providing documents to those with disabilities who find it difficult to use a screen
printing a page for your colleague who refuses to use this newfangled t'internet nonsense.
Unfortunately, printing pages can be a frustrating experience:

text can be too small, too large, or too faint
columns can be too narrow, too wide, or overflow page margins
sections may be cropped or disappear entirely
ink is wasted on unnecessary colored backgrounds and images
l..

Continue Reading

How to Quickly and Easily Remove a Background in Photoshop

This article on how to remove a background in Photoshop remains one of our most popular posts and was updated in 2019 for Adobe Photoshop 2020.

Photoshop offers many different techniques for removing a background from an image. For simple backgrounds, using the standard magic wand tool to select and delete the background may well be more than adequate. For more complicated backgrounds, you might use the Background Eraser tool.

The Background Eraser Tool
The Background Eraser tool samples the color at the center of the brush and then deletes pixels of a similar color as you “paint”. The tool isn’t too difficult to get the hang of. Let me show you how it works.

Remove a Background, Step 1: Open your Image
Start by grabbing an image that you want to remove the background from. I'll be using the image below, as it features areas that range from easy removal through to more challenging spots. I snagged this one for free from Unsplash.

Now let's open it in Photoshop.

Remove a ..

Continue Reading

5 Signs It’s Time to Quit Your Job

“Jerry wouldn't let me go to the emergency room.”

Jenny010137 recounted her story on Reddit. She had a major health crisis, but Jerry, her boss, wasn't buying it.

Jerry wouldn't let me go to the emergency room after the heavy vaginal bleeding I had been experiencing suddenly got way worse. I went over his head and got permission to go. I called my mom, told her to meet me in the ER. The ER nurse said he'd never seen so much blood. An ER nurse said this. It's determined I need a couple of blood transfusions and will be admitted.

Jenny's mom calls Jerry on her behalf.

My mom calls Jerry, who then proceeds to tell her that it's just stress, and I NEED TO GET BACK TO WORK. At this point, I couldn't even lift my own head up, but sure, I can take a bus across town and go back to work.

Doctors told Jenny they found a large growth that needed a biopsy.

They found a large growth that needed a biopsy. Jerry kept insisting that it couldn't be can..

Continue Reading

The Evolution of JavaScript Tooling: A Modern Developer’s Guide

This article was created in partnership with Sencha. Thank you for supporting the partners who make SitePoint possible.

JavaScript application source code has traditionally been hard to understand, due to code being spread across JavaScript, HTML, and CSS files, as well as events and data flowing through a number of non intuitive paths. Like all software, the JavaScript development environment includes bundlers, package managers, version control systems, and test tools. Each of these requires some learning curve.

Inconsistencies and incompatibilities between browsers have historically required various tweaks and special cases to be sprinkled around the code, and very often fixing a bug in one browser breaks something on another browser. As a result, development teams struggle to create and maintain high quality, large-scale applications while the demand for what they do soars, especially at the enterprise-application level where business impact has replaced “How many lines of code ha..

Continue Reading

Understanding and Using rem Units in CSS

CSS units have been the subject of several articles here on SitePoint (such as A Look at Length Units in CSS, The New CSS3 Relative Font Sizing Units, and The Power of em Units in CSS). In this article, we increase the count by having an in-depth look at rem units, which have excellent browser support and a polyfill if you need support for old IE.

This article was updated in December, 2019 to reflect the current state of rem unit sizing with CSS. For more on CSS font and text properties, read our book, CSS Master, 2nd Edition.

What Are rem Units?
You might have encountered the term “R.E.M.” before while listening to the radio or your music player. Unlike their musical counterparts, named for the “Rapid Eye Movement” during deep sleep, in CSS rem stands for “root em”. They won’t make you lose your religion nor believe in a man on the moon. What they can do is help you achieve a harmonious and balanced design.

According to the W3C spec the definition for one rem unit is:

Equal to the..

Continue Reading

How We Can Solve the Cryptocurrency Energy Usage Problem

Bitcoin is still the most important cryptocurrency people know about, and it serves as the entry point of the crypto space. However, every innovative project has to pay its price. For Bitcoin, it is its high carbon footprint created by mining.

Bitcoin mining works by solving cryptographic puzzles, also referred to Proof of Work (PoW). The miner that’s first to find the solution receives a Bitcoin reward. However, this race towards finding the solution comes with high energy usage, as it’s a resource-intensive process requiring a lot of electricity.

Currently, Bitcoin mining uses 58.93 TWh per year. An online tool by the University of Cambridge showed that Bitcoin uses as much energy as the whole of Switzerland. More important is the carbon footprint of Bitcoin. The electricity generated for powering the Bitcoin network equals 22 megatons of CO2 on a yearly basis. You can compare this carbon footprint with the footprint of a city like Kansas City (US).

This article will cover the fol..

Continue Reading

It’s Time to Start Making Your Web Apps Reactive

This article was created in partnership with Manning Publications. Thank you for supporting the partners who make SitePoint possible.

You’ve heard of the principle of “survival of the fittest”, and you know that it’s especially true in web development. Your users expect split-second performance and bug-free interfaces — and if you can’t deliver them, you can be sure they’ll go straight to a competitor who can. But when it comes to survival, it’s important to remember the full principal of evolution: the best way to thrive is to be adaptable to change.

That’s where reactive programming comes in. Reactive applications are created to be adaptable to their environments by design. Right from the start, you’re building something made to react to load, react to failure, and react to your users. Whatever being deployed to production throws at your application, reactive programming will mean it can handle it.

How does reactive programming achieve this? It embeds sound programming principles ..

Continue Reading

The Real Future of Remote Work is Asynchronous

I’ve been working remotely for over a decade – well before the days of tools like Slack or Zoom. In some ways, it was easier back then: you worked from wherever you were and had the space to manage your workload however you wanted. If you desired to go hardcore creative mode at night, sleep in, then leisurely read fiction over brunch, you could.

Now, in the age of the “green dot” or “presence prison,” as Jason Fried calls it, working remotely can be more suffocating than in-person work. The freedom that we worked hard to create — escaping the 9-to-5 — has now turned into constant monitoring, with the expectation that we are on, accessible, productive, and communicative 24/7.

I see this in job positions for remote roles. Companies frequently champion remote, proudly advertising their flexible cultures to only then list that candidates must be based within 60 minutes of Pacific Time Zone, that the hours are set, and standup is at 8:30am daily. One of the benefits of remote work is that..

Continue Reading

7 Ways Developers Can Contribute to Climate Action

Whether you’ve just started out as a software engineer or you’ve been at it for decades, you too can play a role in helping to positively impact climate.

When people first consider this, they tend to think about the impact writing efficient code will have. Of course, you should always write efficient, elegant code. But unless the code you’re creating is going to be used by millions of people, it may not be where you can have the biggest impact from a climate perspective. (Code being used by millions or billions of people is probably highly optimized anyway!)

In this article, we'll look at seven other ways you can help.

Choose Where You Spend Your Career
Being an engineer means you have one of the most sought after, transferable occupations on the planet. In virtually any city in the world, you'll be in demand and probably well paid, so you have plenty of options. Choosing to work in a place that's at the intersection of your cares and your code is one of the easiest w..

Continue Reading

How to Divert Traffic Using IP2Location in a Next.js Website

This article was created in partnership with IP2Location. Thank you for supporting the partners who make SitePoint possible.

In a world where online commerce has become the norm, we need to build websites that are faster, user friendly and more secure than ever. In this article, you’ll learn how to set up a Node.js powered website that’s capable of directing traffic to relevant landing pages based on a visitor's country. You'll also learn how to block anonymous traffic (e.g. Tor) in order to eliminate risks coming from such networks.

In order to implement these features, we'll be using the IP2Proxy web service provided by IP2Location, a Geo IP solutions provider. The web service is a REST API that accepts an IP address and responds with geolocation data in JSON format.

Here are some of the fields that we'll receive:

countryName
cityName
isProxy
proxyType
etc.
We'll use Next.js to build a website containing the following landing pages:

Home Page: API fetchi..

Continue Reading