How Are Your Pull Requests?

Pull requests shouldn't feel like pulling teeth

My college life started in the town of Boston, MA — about 950 miles from my hometown in the Midwest. Since I was living in a large city, paying for parking for my automobile was not an option. My sister and her friend drove me to Boston and helped get me unloaded before headed back to the Midwest. I was grateful.

This was the late 1980s.

Hatchet

Hatchet has grown from the status of a bright idea to a fully realized solutions provider, connecting businesses in Perth with a unique set of comprehensive web services across app development, software development, web design, hosting and databases.

We’re digital agency you bring in when you want a effective, no compromise digital solution, built within the latest technology frameworks in a human centred design.

The post Hatchet appeared first on WeLoveWP.

Using a PostCSS function to automate your responsive workflow

A little while back, you might have bumped into this CSS-Tricks article where I described how a mixin can be used to automate responsive font sizes using RFS. In its latest version, v9, RFS is capable of rescaling any value for value for any CSS property with px or rem units, like margin, padding, border-radius or even box-shadow.

Today, we’ll focus on its PostCSS implementation. Continue reading "Using a PostCSS function to automate your responsive workflow"

How To Create A Real Estate Website In WordPress That Gets Results

Building a badass real estate website in WordPress is no easy feat. But with the help of a few specialised themes and plugins, along with some knowledge of what makes a winning real estate website… you’ll be well on your way to creating a clean, professional site that gets results.

Creating a real estate website in WordPress can be a daunting prospect.

Creating a real estate website in WordPress that stands out from the crowd and gets results?

…Even worse!

Getting to know the unique features and functionalities a site like this requires is key to creating a winning WordPress site of this nature.

Because the truth is, a real estate website is different to any other website you’ve worked on.

The good news is… there are plenty of easy-to-use plugins and out-of-the-box themes you can harness to build a professional and functional site.

The bad news is… you have to know what plugins to use… along with when, where, how, and why to use them!

But don’t worry, in this article we’ll take you through the basic steps you need to follow.

We’ll also touch on what types of themes and plugins you should be utilizing for best results.

Finally, we’ll look into the common qualities and elements that make a real estate website stand out from the crowd.

But first… let’s get some formalities out of the way

Before we dive into this walkthrough, I’m going to assume you already have hosting and a domain sorted…

… I’m also going to assume you have WordPress all ready to go and we can jump into building ourselves a kickass real estate website!

Alright now we have that sorted…

Onto the first step!

1.Choose The Best Real Estate Theme For Your Website

The first step is choosing a theme for your site.

Themes can be incredibly helpful, as real estate websites typically require a lot of specialised functionality – making them not so easy to create from scratch.

You’re also in luck, because there are literally THOUSANDS of WordPress themes to choose from.

However, although there are plenty of “flexible” themes out there that serve all kinds of different industries, for now we’ll just focus on real estate specific themes.

Another good reason to use real estate specific themes is that they come with real estate friendly features.

Here are some examples of real estate WordPress themes and what they offer:

WP Real Estate (Free To Download)

A look at the free theme WP Real Estate

If you’re looking for a free theme option to get started with – WP Real Estate is a fantastic option.

Overall this is a simple, stylish and fast loading WordPress theme specially designed for real estate firms and agents.

Of course, with free themes you can expect the functionality and features to be much lower than paid themes.

The good news is, after downloading this theme you’re immediately recommended a real estate plugin which can help add features like property listing functionalities, search bars, and more.

Other than that, you can expect standard website features like: a featured posts section, customizable headers, and a custom background.

This theme is also dead simple to set up:

All you have to do is download the “.zip” file of your theme on your computer (don’t extract it!)

First find the download link

 

The next step is finding "themes"

Then directly upload the “.zip” file in your dashboard by going to Appearance > Themes > Add New > “Upload.”

Next simple press upload theme and you're done!

You can also install the theme directly from your dashboard:

install your theme directly from the dashboard

Boom! Your theme is all ready to go.

*Note: these same download instructions will apply to most free themes you encounter.

Neptune Real Estate (Free To Download)

Neptune Real Estate is another great theme

Neptune Real Estate is another free WordPress real estate theme which focuses on simple design elements and functionality.

As a result, this theme is more suited to a small real estate website that focuses on a defined region.

When you download the free version of Neptune you can expect features like:

  • Properties custom post type.
  • The ability to list and manage properties.
  • Custom homepage with custom header, property listings, and call to actions.
  • Regular updates.
  • Forum support on wordpress.org.
An example of what the property listings looks like
Easily display your property listings

 

an example of a compelling call to action
The pro version allows more great features

However, if you really want to get serious you can unlock the pro version which comes with a whole host of additional features including: an advanced search mechanism, property slider, custom homepage designs, and more.

RealHomes – Estate Sale and Rental WordPress Theme (Paid)

RealHomes premium theme plugin

RealHomes is the number one real estate theme on ThemeForest – with more than 19,000 people currently using it for their real estate websites.

According to the theme page the team at RealHomes are also always working on improvements and enhancements – so expect this theme to get better with every update!

Some of the handy real estate features of this theme include:

An advanced property search customization – which allows users to easily search for properties.

offer users an advanced search form

Google Maps integration – letting you display your properties on the map with little pin identifiers.

display your listings on Google Maps

Real estate property comparison feature – which visitors can use to easily compare properties they are interested in.

Property layout options – RealHomes also gives you a bunch of different templates for laying out your properties, including list layout, grid layout and half map layout.

Change up the layout of your property listings

Check out more of the features of RealHomes Real estate theme here.

Houzez – Real Estate WordPress Theme (Paid)

The Houzez WordPress theme

Sitting at around the same price as RealHomes, Houzez is another great premium real estate theme option.

This theme in particular is incredibly flexible and gives designers and developers a great platform to show off their creativity and produce high quality work.

Some of the handy real estate features of this theme include:

Full responsiveness – Houzez assure you that they have tested their code and this theme produces a smooth user experience on all platforms.

make sure your real estate website is mobile friendly

Visual composer – If you’re not as experienced in web design or development, you can use this handy feature to see your progress. You can also use the drag and drop builder to easily set up pages.

Use the easy drag and drop builder

Parallax backgrounds – Parallax backgrounds can be a great way to help a real estate website stand out and produce visually impressive backgrounds.

Blog layouts – Another great feature every real estate website needs is a blog. With this feature you can choose between “Default” and “Masonry” blog layouts, to make your blog section both appealing and functional.

Create yourself an amazing real estate website

2.Install Specialized Real Estate Plugins To Add Even More Functionality

Adding plugins to your website can be a great way to make up for functions your real estate theme might be missing.

Using plugins is also a great way to add additional features to a free real estate theme that might not stack up to its premium option.

Check out these real estate-specific plugin examples:

WPL Real Estate (Free To Download)

The WPL real estate free plugin

WPL Real Estate is an all-in-one plugin made by the team at Realtyna, who’ve been hard at it creating real estate solutions since 2007.

As well as a range of features you’ll see below, WPL Real Estate also comes with its own support team, as well as plenty of documentation and a comprehensive knowledge base.

Already this a lot more than you’d usually expect from a free plugin!

WPL Real Estate’s features include:

  • Adding properties with a simple listing wizard.
  • The ability to automatically hide fields that do not contain information on your listings.
  • Categorize listings into room and property types, and help narrow down user options. As well as searching by state, city, and zip code.
  • Enabling the user to switch between two layout modes: lists or grids.
  • Share your property listings through Facebook, Twitter, and email.
  • Display search results on Google Maps.
A look at how your properties appear
Manage and list your properties

 

An example of Google Maps integration
Display your properties on Google Maps

Estatik Real Estate Plugin (Free To Download)

Estatik real estate free plugin

Estatik is another all round free real estate plugin for WordPress that comes packed with a range of valuable features.

This plugin also comes with advanced filters for search for dates, famous properties and locations. And it works perfectly with all of the popular WordPress themes.

Other features include:

  • Customizable categories, types, features, and amenities.
  • Social sharing (Facebook, Twitter, LinkedIn).
  • Photo gallery with video integration (YouTube, Vimeo).
  • A simple field builder which creates unlimited numbers of fields of any type.
  • Google Maps integration.
an example of a property page using this plugin
Show off your properties

 

an example of displaying the listings on a map
Pin point listings on the map

WP Amortization Calculator (Paid)

The WP Amortization calculator

The WP Amortization Calculator is a special calculator add on that can be used for mortgages and other kinds of amortized loan.

This plugin is a great tool for any real estate website and can easily be inserted onto a page, or used as a widget.

The design is clean and simple and fits nicely into WordPress themes of all shapes and sizes.

This calculator can also be used as a lead capture device (you can ask to send a report to visitors email) and an educational tool for visitors to see the costs involved in obtaining a home mortgage.

Real Estate Pro – WordPress Plugin (Paid)

The real estate pro premium plugin

Real Estate Pro is a paid property listing plugin you can add to your WordPress website.

In a nutshell, this premium plugin enables you to add listings, sell properties, manage customer reviews, and more.

This plugin also lets visitors to your website place bids on properties, as well as contacting the property owners, and joining up to your list if they want valuable insights and updates.

Real Estate Pro also comes fully responsive and can be integrated with services such as MailChimp, PayPal, Stripe, and more.

It also includes a visual composer you can get your property listings up quick smart and complete your real estate website.

An example of how people can bid on your properties
Let visitors place bids on your properties

 

An example of giving people listing options
Segment and diversify your properties

3.Make Sure Your Real Estate Website Is User-Friendly

It’s all well and good to install a real estate theme and add a few plugins.

But according to HubSpot there are also some basic rules and principles that every successful real estate website should adhere to.

After all, the goal of a real estate website should be to either capture a lead, or have a lead get in touch with the real estate agent.

On that note, here are five bonus tips to consider when creating a real estate website:

1.Ensure The Website Is Easy To Navigate And Explore

an example of a well done navigation menu
Simple navigation helps lessen confusion and overwhelm

The simple truth is, if a website is too confusing or overwhelming for someone when they land, it’s more likely they will bounce from the page.

That’s why it’s important to keep the site navigation as clean and simple as possible.

Something as basic as having the main points of interest as menu items at the top of the page – with other less important pages coming under sub-menus… will declutter the page and make a huge difference.

Another tip is to make sure your menu is visible no matter what page the user navigates to.

If you’re looking for a comprehensive menu plugin for your real estate website, you can’t go past UberMenu.

2.Set Up A Simple Lead Capture And Contact Flow

An example of lead capture
Capture leads with a valuable and helpful piece of content

It’s vital to ensure a real estate website can easily capture visitor information.

Most real estate websites will have “lead magnets” like market reports and other helpful guides (for home buyers or sellers) that visitors can download.

Also remember to include a simple contact page or form on the home page.

Another tool many real estate websites use now is “chatbots.”

a look at a chatbot in action

Chatbots are a great way to help qualify visitors and establish what their needs are.

They’re also a great way to improve user experience and assist them with any problems or questions they might have.

ChatBot for WordPress is a great option if you’re looking for a chatbot plugin.

3.Make Sure Your Real Estate Website Is Responsive

An example of how a responsive website looks like on different devices

We’ve known for a while now that real estate (along with every other industry) is moving online.

But it’s not just online…

It’s at the gym…

It’s at the mechanics…

It’s in our pockets at all times!

Another crucial element is making sure a real estate website is responsive.

This means the screen will adapt to fit no matter what the user is using – whether it be on a tablet or a mobile phone.

In fact, a lot of businesses are taking a “mobile first” approach, making sure their websites are designed for mobile first and then designing their websites for laptops and tablets.

Although most real estate themes are already responsive, if you’re looking for a mobile response plugin try: AMP for WordPress.

4.Apply User Content And Resource Functionality

An example of a blog section on a website
A blog can help you communicate with your audience

As mentioned earlier, offering downloadable content can be a great way for a real estate website to capture leads and provide value for potential sellers or buyers.

As well as downloadable guides and reports, you may want to consider setting up blog functionality on the website to enable the user to post regular articles for their audience.

Providing valuable and helpful content is also a great way to establish authority and show the owner of the website is a thought leader in his or her industry.

As a bonus, posting regular content on a website helps improve SEO (search engine optimization) and a website’s Google search rankings.

5.Use High Quality Imagery and Video

When it comes to real estate websites the old adage “show don’t tell” couldn’t be more true.

An example of how much of a difference great photography makes

That’s why it’s crucial a real estate website uses high quality photos and videos for its home listings.

a beautiful picture can sell a house

Video especially has taken off in the real estate world, with virtual tours of the property and drone footage becoming a norm for real estate listing videos

This doesn’t only apply to listings…

The imagery, design, copy, and layout of the rest of the website should also be on point and reflect the brand.

Stein team have their design and branding on point

 

another example of great design and branding in action

 

you want to make sure your design stays consistent throughout

Also remember that high quality images and videos also have the potential to slow a website down.

So it’s important to make sure you optimize all images for optimal page loading speed.

Well whaddaya know… we’ve got our own plugin for that!

Use Smush if you need help optimizing your high quality images. Check out how it works below:

Ready To Create A Kickass Real Estate Website Of Your Own?

To sum up:

If you want to create a real estate website in WordPress that gets results:

Choose the right real estate theme for your website… whether it be paid themes or free themes.

If your website requires more functionality use plugins to fill in the gaps.

The themes and plugins you choose will largely depend on the type of real estate website you’re setting up and what the owner wishes to achieve.

And finally, remember to consider the practical elements a real estate website should include.

Ensure optimal functionality for elements like lead capture forms, chat bots, blog pages, high quality photos and videos etc.

Also feel free to fire through any of your real estate website questions in the comments, our team of experts are always on hand to help!

Golden Gate SEO

Golden Gate SEO is the premier SEO company. Our proven search engine marketing techniques have helped hundreds of clients transform their businesses to the next level. We offer unparalleled search engine optimization, paid and social media marketing services.

The post Golden Gate SEO appeared first on WeLoveWP.

Bamboo Sushi

Bamboo Sushi is the first in a series of restaurants from Sustainable Restaurant Group whose mission to provide the most ethically caught fish with the lowest carbon footprint possible. To help tell their story, we created an interactive platform that not only showcases their food, but helps to tell the story of where they get their ingredients and how they get to each of their restaurant’s location. Our goal was to create a design that felt extremely high-end with a focus on a nontraditional navigation and rich user experience. When browsing the site you feel transported into another world, immersed in the Bamboo Sushi brand.

We also took a mobile first design approach to this project, given that the majority of the users browse the site on mobile devises. This allowed us the opportunity to re-imagine what the mobile experience was going to be like. Users can use the intuitive swipe gesture to navigate through the content on their phones, in addition to using the traditional navigation.

The post Bamboo Sushi appeared first on WeLoveWP.

Ketamine Media

Ketamine Media was founded to help physicians raise awareness about the clinical use of Ketamine. Our agency works exclusively with infusion centers on a national level. Our mission is to help connect treatment providers with individuals searching for new treatment options to battle depression and other treatment resistant conditions.

The post Ketamine Media appeared first on WeLoveWP.

Studio 313

We have finally had the chance to finish off our new website after having to put it aside for what seems to have been forever.

This is our new WordPress studio portfolio website and we love it. Bright, informal with a little bit of animation

The post Studio 313 appeared first on WeLoveWP.

The Ultimate Guide to Image Optimization

Images are one of the most important elements on your site and getting them right can be the difference between a popular site that provides an awesome user experience and one that doesn’t get any traffic or conversions. But images are, well, complicated.

There’s a lot you need to do to get them perfect so you get the most benefit.

In this ultimate WordPress Image Optimization guide, I’m going to give you all the information you need to optimize your images. We’re going to go through everything:

We’ll cover all the important subtopics and information we’ve shared in our previous image optimization posts as concisely as possible, so you’ll be a WordPress image optimizer in no time. If you’d like a much more thorough explanation of these topics, I’ve included links throughout this post to our in-depth tutorials.

Preparing Your Images

Optimizing Your Images in WordPress

Image SEO

Serving Images

If you’re wondering what the best WordPress image optimizer is, look no further than our very own Smush Pro. Combine it with Hummingbird and SmartCrawl SEO, all three can dramatically improve the performance of your images. You can try all three on your site with a free 30-day trial.

Looking to optimize images on a low traffic, individual, or hobby site? We also have a free version of Smush available on WordPress.org

How to Optimize Images

Before you ever upload an image to WordPress, you need to make sure that your image is the best it can be when you make it. You need to compose it properly, size it perfectly, use the appropriate image format and give it a descriptive file name.

Composing Images

The most important question when creating your images is the following:

Is this image necessary?

Images take a lot of resources to deliver to your visitors. They’re “expensive” site assets so you shouldn’t use them just to fill a space. Create original images that enhance your content and use inexpensive assets, such as headings and text, instead of images to communicate and add style whenever possible.

Never add text to your images. This practice doesn’t follow accessibility best practices and if your images shrink down to be mobile-responsive, then the text will be smaller and harder to read. Plus, images with text need to be of much higher quality to preserve the fine detail of the letters. Don’t waste resources, create the text over your images with CSS instead, for better results.

Giving up images is hard, I know. They can really make your site look great, but consider this, sessions that convert users had 38% fewer images than sessions that didn’t convert, so more images don’t add to the bottom line.

Sizing and Cropping Images

When it comes to images, size matters! And bigger is not better. GTmetrix and Google PageSpeed Insights recommend scaling your images to fit the container they will inhabit to improve performance.

Screenshot of GTmetrix Serve Scaled Images Message
If you do nothing else for image optimization, at the very least scale your images. It will make a huge difference if you’ve been doing it wrong.

Images that are oversized for their container need to be manually shrunk by the browser. This wastes time and data when loading your web pages, without providing any benefit in performance and quality.

How to Reduce Image Size in WordPress

The first step is to use the developer tools in your browser to find out the different sizes of the image containers on your site.

Watch our quick tutorial on how to detect incorrectly sized images in WordPress.

Then use an image editor to resize the image to fit the largest container it will inhabit on your site. If you want to use Retina images on your site, you’ll need double both the width and height of the largest container. We’ll talk more about Retina images below.

If you’re scaling a new image for your site, then all that’s left is to upload the image and use it in the container it was sized for. If you’re correcting an existing image on the site, upload the image and replace the URL of the old image with the new one.

Smush Pro can also resize your images automatically. So if you have a mature site with lots of images, let Smush take care of the scaling. Try Smush Pro free for 30-days.

Cropping Images

When cropping your images, try to create tighter crops and cut the excess detail and space from the image.

4:3 and 16:9 ratios are better for image SEO, so if your goal is to get the image ranked in image search, aim for an image that is not panoramic or tall and skinny.

Using the Right Image Format for the Job

Are you using PNGs for everything? Be honest. The best way to optimize images in WordPress without a plugin is to use the right image format.

Each file type was designed for a specific use case and has its own strengths and weaknesses.

Additional image file capabilities (such as transparency), unnecessary detail and too many colors all add bloat to your images. Sometimes, these are necessary and other times they’re not.

The key is to use the appropriate image file with the right capabilities to suit your needs.

We put together a downloadable PDF cheat sheet for you to be able to refer to! Click here to get your copy

Image file format infographic
Use the Smush guide to file formats to find the best file type for your images.

WordPress Image Resize Compression

There are two kinds of image graphics types, vector images, and raster images.

Vector images are mathematically generated geometric shapes that can be resized without a loss of quality.

Raster images consist of tiny blocks called pixels arranged on a grid. Raster images only appear high quality at the size they were meant to be displayed at or smaller. Otherwise, the image will appear pixelated.

WordPress Image Compression

Another thing to keep in mind when choosing your image file type is the type of image compression that each one uses as this will affect the quality of the image when it is decoded and appears on your site.

Lossy Compression permanently removes image data when the image is compressed. Some detail is imperceivable to the human eye, so this doesn’t always create a visible loss of quality.

Generally, lossy compression between 75-100% will maintain the integrity and high quality of the image, yet at 75% the image is half as large. Most social networks compress their images between the 70-85% range when you upload them.

Lossless compression preserves all the data so nothing is lost and the image can be reproduced exactly with no loss in quality. The downside is a much larger file size. Here’s a comparison.

Image File Types

JPEG

JPEG images are best for large photographs.

  • JPEGS are the standard file type produced by consumer cameras and mobile devices.
  • JPEGS can contain millions of colors and uses lossy compression to produce a small file size.
  • They’re supported in all major browsers.
  • JPEGs don’t support transparency or animation.

PNG

PNG images are best when preserving detail (such as screenshot text) is critical.

  • PNGs utilize lossless image compression, so they’re larger than comparable JPEGs.
  • There are 3 kinds of PNGs:
    • PNG-8 supports 256 indexed colors and is like the GIF of PNGs.
    • PNG-24 supports 24-bit colors to create a palette of millions of colors so it’s more like a JPEG.
    • PNG-32 supports 24-bit colors plus an extra alpha channel for advanced transparency capabilities.
  • All three PNG types support transparency, but they do so in different ways. You can get a full explanation of the different types of PNGs and how they handle transparency in this post.

WebP

WebP is Google’s open source image format that combines the best of JPEG and PNG, but with much smaller file size. They’re close to being widely supported.

There are two types of WebP image files

  • The first is known simply as WebP and uses lossy compression. It’s like the WebP version of a JPEG.
  • The second type is known as WebP Lossless and it is more like the PNG equivalent because it uses lossless compression.

SVG

SVG is an XML-based markup language that allows you to create two-dimensional shapes to create vector graphics. It’s best suited for simple shapes such as logos, graphs, flags, icons, and geometric shapes.

  • SVGs don’t work well for photographs.
  • They’re compatible with all browsers.
  • Since they’re technically a markup language, WordPress doesn’t allow SVGs by default to prevent malware injection. You should only allow trusted users who understand the risks of using SVGs the ability to use them on your site.

GIF

GIFs are great for animating dumb memes and not much else.

  • GIFs produce exceptionally large file sizes, especially if the image includes animations. For animations, MP4s or WebM files have a smaller file size.
  • GIFs have a limited color palette of 256 colors and support transparency.
  • They’re compatible with all browsers.
  • There’s no consensus on how to pronounce them so who needs ‘em.
diagram summarizing capabilities for JPEG, SVG, PNG, WebP and GIF
Here’s a quick functionality recap

Image Titles

Once you’ve selected the right format in which to save your image, you need to change the default image title generated by your camera.

Give your images succinct and descriptive titles. Use your keywords if they appropriately describe the image. If your keywords don’t describe your image, don’t use them in the image title. I’ll show you a more appropriate place for them in the SEO section of this post.

Bulk Image Editors

Creating a batch of images for a new site or going back to fix all the issues with the images currently on your site can take a lot of time. Luckily, there are several tools that can help you process your image in bulk.

Lightroom Classic was designed to manage non-destructive edits to your images. Use it to bulk scale, crop or rename the JPEG images from your camera.

Photoshop can help you bulk edit PNGs or JPEGs. Use the image processor or create custom Photoshop Actions to record a complex sequence of edits and then apply them to other images.

Optimizing Your Images in WordPress

Preparing your images correctly can prevent a lot of problems before they begin. Once you’ve got your images ready, then WordPress has some awesome features to help you manage your images and make them look their best.

WordPress Default Image Sizes

Every time you upload an image into the WordPress media library, WordPress creates the following additional image size by default:

  • Thumbnail
  • Medium
  • Medium Large
  • Large
Screenshot of WordPress Media settings
The default WordPress image sizes, except for medium_large which is hidden by default

If your theme specifies additional image sizes for your archive page, the home page, etc. WordPress creates those as well. WordPress also preserves the original size you upload and names it Full as in full-size.

To do less work manually resizing your images for the different containers on your site, you can adjust the defaults in the Media > Settings section or add custom sizes so you’ll have more options to choose from. Just avoid going overboard and creating images for every conceivable purpose or else you’re going to burn through the disk space on your hosting server.

When you make a change to the way that WordPress creates additional images, then it doesn’t update the images that are already in your media library. To change the images you’ve already uploaded, you’ll have to use the popular Regenerate Thumbnails plugin.

You’ll need to regenerate thumbnails if you’re doing any of the following:

  • modifying the WordPress default image sizes
  • adding custom image sizes or
  • switching over to a new theme that has different custom sizes.

Responsive Images

One of the uses for all the varying image sizes is so WordPress can serve responsive images.

Responsive image functionality was introduced in WordPress version 4.4 and is enabled by default. It works by using the srcset attribute to give the browser a list of multiple images at various sizes to choose from.

Instead of downloading and serving the largest image file every time, the browser loads the appropriate size file for the device. If the visitor is using a mobile device, they’ll receive a smaller image in the srcset. If they’re visiting your site on a desktop Retina device, then they’ll receive the huge full-size Retina-ready file.

WordPress writes the srcset code and adds images to the set automatically, but it’s still a good idea that nothing in your theme or plugins is interfering with this process as a part of your image optimization audit.

Retina Images

Retina and other high definition screens have 4x as many pixels. To preserve the detail and sharpness of your images on high definition screens, you need to create Retina images with enough data to fill all those new pixels and then only serve them to Retina devices.

How to serve Retina images in WordPress

Step 1: Produce images with double the pixel dimensions

To produce Retina images in WordPress with enough data for every pixel, you need to double the pixel dimensions for every image you upload.

  • If you have a large hero image that is 1600px wide and 400px tall, you need to produce an image that is 3200px wide and 800px tall.
  • If the width of your blog is 800px, then the images for your blog posts will have to have a width of 1600px and so forth.

You only need to double the pixel dimensions for the largest possible size that your image will display at. You do NOT need to create images with double dimensions for every possible responsive size.

Step 2: Serve Retina Images to Retina devices

Option 1: One of the better ways to serve Retina images is by using the srcset attribute. You simply add Retina images to the source set that WordPress uses to generate responsive images.

Option 2: Install and Configure the free WordPress Retina 2x plugin.

Step 3: Upload your Retina Images to WordPress and Use Them on Your Site

When you use the Retina image on your site, use the image variation that is half the width and height of the full size.

Screenshot of media library
The image has a width of 1200px, but I’ll need to use the version that is 600px in order to get Retina quality

Next-Gen WebP Files

Since next-generation images such as WebP are not widely supported, we can also use srcset to serve WebP images for compatible browsers.

First, you’ll need to use a WebP converter to convert existing images in your media library as well as future uploads. Then you need to determine if the visitor’s browser supports WebP images.

Finally, you can use srcset or a different method to serve WebP images if they are supported or a legacy file format like PNG or JPEG if they aren’t.

Smush Pro can convert the images that use the tag on your site to WebP and serve them to compatible browsers with her CDN. You’ll need to use a different method for CSS background images though. Get a free trial and see what a difference it makes for your site.

Check out the video below for an example of how to use a WordPress image optimizer to serve next-gen images.

Image SEO

Image SEO has gained importance recently and there’s a lot of opportunities to drive traffic with images. Unlike written content, where duplicate content is penalized, with images, the best-optimized image will “win” in search results and be the best ranked.

Properly identifying your images using the right HTML attributes can help your images be discovered in image search. Here are the important ones you need to fill out every time.

Image Title

The image title in WordPress is different from the file name title. The file title you add when creating an image in Photoshop or other image editor is more important than the image title field in the WordPress media library. The former contributes to SEO, that latter can be left out entirely.

Alt Text

Alt text isn’t just important for SEO, it’s also important for accessibility. To write an effective alt tag for your image, you’ll want to write a succinct description that communicates what the image contains or is trying to convey to someone who can’t see the image, either because they’re using a screen reader, or can’t download the image.

Screenshot where to add alt text in image block
Add your alt text here

Image Caption

Captions and the other text surrounding your image, give your image context. They also help Google understand what the image is about. Not all images need a caption, but captions function similarly to call outs in the body text. Because they’re set apart from the rest of your text and highlighted, they’re four times as likely to be read.

Other Elements on the Page Near the Image

Google also takes the whole page into account when trying to understand your images. What is the page title? What is the URL? Even though these are not related to your image directly, Google uses them as a ranking factor. Include your keywords and related phrases in your page title, page URL and image URL if possible.

Image Sitemaps

In order to make sure that Google indexes all your images, you need to create an image sitemap. Sitemaps are especially important if you update your content frequently, have an eCommerce site or if you have a new site and want Google to index your images as quickly as possible.

If you want an easy solution, you can use SmartCrawl to generate a sitemap.

Screenshot SmartCrawl advanced settings, activate include images
Flip the switch to include images in the sitemap SmartCrawl generates

Social Media Tags

Social media tags are a way for you to label your content, so when someone shares it on a social network, they share what you want them to share. Facebook, Twitter, LinkedIn, and Pinterest all support Open Graph, which is Facebook’s social media tags language. Twitter has its own meta tags but will recognize Open Graph data if Twitter social media tags aren’t available.

The important Open Graph tag for your images is og:image and allows you to specify what image you want Facebook and other social networks to display when someone shares your post.

Serving Images

The last thing you need to pay attention to when optimizing images is how your images are delivered. There are several tools you can use in WordPress to improve image optimization and PageSpeed. Smush Pro has lazy loading and her own CDN. Hummingbird can help with browser caching. Get a free trial for 30-days and try the pro versions of both on your site.

Lazy Loading

Lazy loading is a technique for improving initial page speed and payload by deferring the loading of non-critical assets that are not currently in the browser viewport. To defer offscreen images in WordPress basically means to wait to load the images we can’t see yet.

Browser Caching

Caching is a reliable way to improve site speed for your visitors by storing assets in a cache for faster retrieval. With HTTP caching, the browser stores a copy of assets (such as images) downloaded via HTTP by the user in its cache so it will be able to retrieve them without making an additional trip to the server. This dramatically improves performance for repeat visitors when done properly.

Content Delivery Networks, CDN

Instead of only serving your images from your web server in a single location, – CDNs have locations all over the globe so the data transfer required to load your images happens much more quickly.

One thing to keep in mind if you’re using a CDN to serve your images is you’ll want to avoid changing CDNs or activating a CDN and deactivating. This will change the image URLs and can negatively impact your image SEO.

Additional Resources

For more detailed tutorials on image optimization, check out our other posts on the topic:

That’s All There is to WordPress Image Optimization

There’s a lot to image optimization, so the smartest way to get started is to audit your site and see where your images stand. Focus on the most important things first, scaling images and adding alt text are two things that are time intensive, but can help you make a dramatic improvement.

Other image optimization tactics such as enabling lazy loading, using browser caching, adding a CDN, creating an image sitemap, using next-gen images can be done in one fell swoop with a WordPress image optimizer like Smush Pro. So if you don’t have a lot of time or are managing a bunch of sites, using a WordPress automatic image compression plugin is good places to start.

Lastly, using powerful bulk image editors such as Lightroom and Photoshop can help you with improving individual images much more quickly.

If you’re serious about improving your image optimization game, look no further than WPMU DEV’s optimization trifecta: Hummingbird, SmartCrawl and the crazy popular Smush Pro. Smush Pro is the best WordPress image optimizer because it does it all. You can try all three on your site with a free 30-day trial. If you’ve never taken image optimization seriously, you’re going to be pleasantly surprised by how much your site’s performance will improve.

Wesley College

Founded in 1923, Wesley College is a day and boarding school in Perth, Western Australia, offering exceptional campus facilities and unique student & community programs.

The post Wesley College appeared first on WeLoveWP.

Planning for Responsive Images

The first time I made an image responsive, it was as simple as coding these four lines:

img {
  max-width: 100%;
  height auto; /* default */
}

Though that worked for me as a developer, it wasn’t the best for the audience. What happens if the the image in the src attribute is heavy? On high-end developer devices (like mine with 16GB RAM), few or no performance problems occur. But on low-end devices? It’s another story.

image at multiple screen sizes

The above illustration isn’t detailed enough. I’m from Nigeria and, if your product works in Africa, then you shouldn’t be looking at that. Look at this graph instead:

Nowadays, the lowest-priced iPhone sells for an average of $300. The average African can’t afford it even though iPhone is a threshold for measuring fast devices.

That’s all the business analysis you need to understand that CSS width doesn’t cut it for responsive images. What would, you ask? Let me first explain what images are about.

Nuances of images

Images are appealing to users but are a painstaking challenge for us developers who must consider the following factors:

  • Format
  • Disk size
  • Render dimension (layout width and height in the browser)
  • Original dimension (original width and height)
  • Aspect ratio

So, how do we pick the right parameters and deftly mix and match them to deliver an optimal experience for your audience? The answer, in turn, depends on the answers to these questions:

  • Are the images created dynamically by the user or statically by a design team?
  • If the width and height of the image are changed disproportionately, would that affect the quality?
  • Are all the images rendered at the same width and height? When rendered, must they have a specific aspect ratio or one that’s entirely different?
  • What must be considered when presenting the images on different viewports?

Jot down your answers. They will not only help you understand your images — their sources, technical requirements and such — but also enable you to make the right choices in delivery.

Provisional strategies for image delivery

Image delivery has evolved from a simple addition of URLs to the src attribute to complex scenarios. Before delving into them, let’s talk about the multiple options for presenting images so that you can devise a strategy on how and when to deliver and render yours.

First, identify the sources of the images. That way, the number of obscure edge cases can be reduced and the images can be handled as efficiently as possible.

In general, images are either:

  • Dynamic: Dynamic images are uploaded by the audience, having been generated by other events in the system.
  • Static: A photographer, designer, or you (the developer) create the images for the website.

Let's dig into strategy for each of this types of images.

Strategy for dynamic images

Static images are fairly easy to work with. On the other hand, dynamic images are tricky and prone to problems. What can be done to mitigate their dynamic nature and make them more predictable like static images? Two things: validation and intelligent cropping.

Validation

Set out a few rules for the audience on what is acceptable and what is not. Nowadays, we can validate all the properties of an image, namely:

  • Format
  • Disk size
  • Dimension
  • Aspect ratio

Note: An image’s render size is determined during rendering, hence no validation on our part.

After validation, a predictable set of images would emerge, which are easier to consume.

Intelligent Cropping

Another strategy for handling dynamic images is to crop them intelligently to avoid deleting important content and refocus on (or re-center) the primary content. That’s hard to do. However, you can take advantage of the artificial intelligence offered by open-source tools or SaaS companies that specialize in image management. An example is in the upcoming sections.


Once a strategy has been nailed down for dynamic images, create a rule table with all the layout options for the images. Below is an example. It's even worth looking into analytics to determine the most important devices and viewport sizes.

Browser Viewport HP Laptop PS4 Slim Camera Lens / Aspect Ratio
< 300 100 vw 100 vw 100 vw/1:2
300 - 699 100 vw 100 vw 100 vw/1:1
700 - 999 50 vw 50 vw 50 vw/1:1
> 999 33 vw 33 vw 100 vw/1:2

The bare (sub-optimal) minimum

Now set aside the complexities of responsiveness and just do what we do best — simple HTML markup with maximum-width CSS.

The following code renders a few images:

<main>
  <figure>
    <img src="https://res.cloudinary.com/...w700/ps4-slim.jpg" alt="PS4 Slim">
  </figure>
      
  <figure>
    <img src="https://res.cloudinary.com/...w700/x-box-one-s.jpg" alt="X Box One S">
  </figure>
      
  <!-- More images -->
    
  <figure>
    <img src="https://res.cloudinary.com/...w700/tv.jpg" alt="Tv">
  </figure>
</main>

Note: The ellipsis (...) in the image URL specifies the folder, dimension, and cropping strategy, which are too much detail to include, hence the truncation to focus on what matters now. For the complete version, see the CodePen example down below.

This is the shortest CSS example on the Internet that makes images responsive:

/* The parent container */
main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

img {
  max-width: 100%;
}

If the images do not have a uniform width and height, replace max-width with object-fit and set the value to cover.

Jo Franchetti’s blog post on common responsive layouts with CSS Grid explains how the value of grid-template-columns makes the entire layout adaptive (responsive).

See the Pen
Grid Gallery
by Chris Nwamba (@codebeast)
on CodePen.

The above is not what we are looking for, however, because...

  • the image size and weight are the same on both high-end and low-end devices, and
  • we might want to be stricter with the image width instead of setting it to 250 and letting it grow.

Well, this section covers "the bare minimum" so that’s it.

Layout variations

The worst thing that can happen to an image layout is mismanagement of expectations. Because images might have varying dimensions (width and height), we must specify how to render the images.

Should we intelligently crop all the images to a uniform dimension? Should we retain the aspect ratio for a viewport and alter the ratio for a different one? The ball is in our court.

In case of images in a grid, such as those in the example above with different aspect ratios, we can apply the technique of art direction to render the images. Art direction can help achieve something like this:

For details on resolution switching and art direction in responsive images, read Jason Grigsby’s series. Another informative reference is Eric Portis’s Responsive Images Guide, parts 1, 2, and 3.

See the code example below.

<main>
  <figure>
    <picture>
      <source media="(min-width: 900px)" srcset="https://res.cloudinary.com/.../c_fill,g_auto,h_1400,w_700/camera-lens.jpg">
      
      <img src="https://res.cloudinary.com/.../c_fill,g_auto,h_700,w_700/camera-lens.jpg" alt="Camera lens">
    </picture>
  </figure>
  
  <figure>
    <picture>
      <source media="(min-width: 700px)" srcset="https://res.cloudinary.com/.../c_fill,g_auto,h_1000,w_1000/ps4-pro.jpg"></source>
    </picture>
    <img src="https://res.cloudinary.com/.../c_fill,g_auto,h_700,w_700/ps4-pro.jpg" alt="PS4 Pro">
  </figure>
</main>

Instead of rendering only one 700px wide image, we render 700px x 700px only if the viewport width exceeds 700px. If the viewport is larger, then the following rendering occurs:

  • Camera lens images are rendered as a portrait image of 700px in width and 1000px. in height (700px x 1000px).
  • PS4 Pro images are rendered at 1000px x 1000px.

Art direction

By cropping images to make them responsive, we might inadvertently delete the primary content, like the face of the subject. As mentioned previously, AI open-source tools can help crop intelligently and refocus on the primary objects of images. In addition, Nadav Soferman’s post on smart cropping is a useful start guide.

Strict grid and spanning

The first example on responsive images in this post is a flexible one. At a minimum of 300px width, grid items automagically flow into place according to the viewport width. Terrific.

On the other hand, we might want to apply a stricter rule to the grid items based on the design specifications. In that case, media queries come in handy.

Alternatively, we can leverage the grid-span capability to create grid items of varied widths and lengths:

@media(min-width: 700px) {
  main {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media(min-width: 900px) {
  main {
    display: grid;
    grid-template-columns: repeat(3, 1fr)
  }
  figure:nth-child(3) {
    grid-row: span 2;
  }
  figure:nth-child(4) {
    grid-column: span 2;
    grid-row: span 2;
  }
}

For an image that is 1000px x 1000px square on a wide viewport, we can span it to take two grid cells on both row and column. The image that changes to a portrait orientation (700px x 1000px) on a wider viewport can take two cells on a row.

See the Pen
Grid Gallery [Art Direction]
by Chris Nwamba (@codebeast)
on CodePen.

Progressive optimization

Blind optimization is as lame as no optimization. Don’t focus on optimization without predefining the appropriate measurements. And don’t optimize if the optimization is not backed by data.

Nonetheless, ample room exists for optimization in the above examples. We started with the bare minimum, showed you some cool tricks, and now we have a working, responsive grid. The next question to ask is, "If the page contains 20-100 images, how good will the user experience be?"

Here’s the answer: We must ensure that in the case of numerous images for rendering, their size fits the device that renders them. To accomplish that, we need to specify the URLs of several images instead of one. The browser would pick the right (most optimal) one according to the criteria. This technique is called resolution switching in responsive images. See this code example:

<img 
  srcset="https://res.cloudinary.com/.../h_300,w_300/v1548054527/ps4.jpg 300w,
          https://res.cloudinary.com/.../h_700,w_700/v1548054527/ps4.jpg 700w,
          https://res.cloudinary.com/.../h_1000,w_1000/v1548054527/ps4.jpg 1000w"
             
  sizes="(max-width: 700px) 100vw, (max-width: 900px) 50vw, 33vw"
  src="https://res.cloudinary.com/.../h_700,w_700/v1548054527/ps4.jpg 700w"
  alt="PS4 Slim">

Harry Roberts’s tweet intuitively explains what happens:

When I first tried resolution switching, I got confused and tweeted:

Hats off to Jason Grigsby for the clarification in his replies.

Thanks to resolution switching, if the browser is resized, then it downloads the right image for the right viewport; hence small images for small phones (good on CPU and RAM) and larger images for larger viewports.

The above table shows that the browser downloads the same image (blue rectangle) with different disk sizes (red rectangle).

See the Pen
Grid Gallery [Optimized]
by Chris Nwamba (@codebeast)
on CodePen.

Cloudinary’s open-source and free Responsive Image Breakpoints Generator is extremely useful for adapting website images to multiple screen sizes. However, in many cases, setting srcset and sizes alone would suffice.

Conclusion

This article aims at affording simple yet effective guidelines for setting up responsive images and layouts in light of the many—and potentially confusing—options available. Do familiarize yourself with CSS grid, art direction, and resolution switching and you’ll be a ninja in short order. Keep practicing!

The post Planning for Responsive Images appeared first on CSS-Tricks.

Responsive Designs and CSS Custom Properties: Defining Variables and Breakpoints

CSS custom properties (a.k.a. CSS variables) are becoming more and more popular. They finally reached decent browser support and are slowly making their way into various production environments. The popularity of custom properties shouldn’t come as a surprise, because they can be really helpful in numerous use cases, including managing color palettes, customizing components, and theming. But CSS variables can also be really helpful when it comes to responsive design.

Article Series:

  1. Defining Variables and Breakpoints (This Post)
  2. Building a Flexible Grid System (Coming Tomorrow!)

Let’s consider an <article> element with a heading and a paragraph inside:

<article class="post">
	<h2 class="heading">Post's heading</h2>
	<p class="paragraph">
		Lorem ipsum dolor sit amet, consectetur adipisicing elit.
		Laudantium numquam adipisci recusandae officiis dolore tenetur,
		nisi, beatae praesentium, soluta ullam suscipit quas?
	</p>
</article>

It’s a common scenario in such a case to change some sizes and dimensions depending on the viewport’s width. One way to accomplish this is by using media queries:

.post {
	padding: 0.5rem 1rem;
	margin: 0.5rem auto 1rem;
}

.heading {
	font-size: 2rem;
}

@media (min-width: 576px) {
	.post {
		padding: 1rem 2rem;
		margin: 1rem auto 2rem;
	}
	
	.heading {
		font-size: 3rem;
	}
}

See the Pen
#1 Building responsive features with CSS custom properties
by Mikołaj (@mikolajdobrucki)
on CodePen.

Such an approach gives us an easy way to control CSS properties on different screen sizes. However, it may be hard to maintain as the complexity of a project grows. When using media queries, keeping code readable and DRY at the same time quite often turns out to be challenging.

The most common challenges when scaling this pattern include:

  • Repeated selectors: Apart from bloating code with multiple declarations, it also makes future refactoring more difficult, e.g. every time a class name changes it requires remembering to update it in multiple places.
  • Repeated properties: Notice that when overwriting CSS rules within media queries, it requires repeating the entire declaration (e.g. font-size: 3rem;) even though it’s just the value (3rem) that actually changes.
  • Repeated media queries: To keep responsive styles contextual, it’s a common practice to include the same media queries in multiple places, close to the styles they override. Unfortunately, it not only makes code heavier, but also might make breakpoints much harder to maintain. On the other hand, keeping all responsive styles in one place, away from their original declarations, may be very confusing: we end up with multiple references to the same elements sitting in completely different places.

We can argue that repeated declarations and queries shouldn’t be such a big deal with proper file compression enabled, at least as long as we’re referring to performance. We can also merge multiple queries and optimize your code with post-processing tools. But wouldn’t it be easier to avoid these issues altogether?

There’s a lot of ways to avoid the issues listed above. One of them, that we will explore in this article, is to use CSS custom properties.

Using CSS variables for property values

There are plenty of amazing articles on the web explaining the concept of CSS custom properties. If you haven’t got chance to get familiar with them yet, I would recommend starting with one of the beginner articles on this topic such as this awesome piece by Serg Hospodarets as we are not going to get into details of the basic usage in this article.

The most common way of utilizing CSS custom properties in responsive design is to use variables to store values that change inside of media queries. To accomplish this, declare a variable that holds a value that is supposed to change, and then reassign it inside of a media query:

:root {
  --responsive-padding: 1rem;
}

@media (min-width: 576px) {                             
  :root {
    --responsive-padding: 2rem;
  }
}

.foo {
	padding: var(--responsive-padding);
}

Assigning variables to the :root selector is not always a good idea. Same as in JavaScript, having many global variables is considered a bad practice. In real life, try to declare the custom properties in the scope they will actually be used.

This way, we are avoiding multiple rules of the .foo class. We are also separating the logic (changing values) from the actual designs (CSS declarations). Adapting this approach in our example from above gives us the following CSS:

.post {
	--post-vertical-padding: 0.5rem;
	--post-horizontal-padding: 1rem;
	--post-top-margin: 0.5rem;
	--post-bottom-margin: 1rem;
	--heading-font-size: 2rem;
}

@media (min-width: 576px) {
	.post {
		--post-vertical-padding: 1rem;
		--post-horizontal-padding: 2rem;
		--post-top-margin: 1rem;
		--post-bottom-margin: 2rem;
		--heading-font-size: 3rem;
	}
}

.post {
	padding: var(--post-vertical-padding) var(--post-horizontal-padding);
	margin: var(--post-top-margin) auto  var(--post-bottom-margin);
}

.heading {
	font-size: var(--heading-font-size);
}

See the Pen
#2 Building responsive features with CSS custom properties
by Mikołaj (@mikolajdobrucki)
on CodePen.

Notice that the use of variables in shorthand properties (e.g. padding, margin or font) allow some very interesting repercussions. As custom properties may hold almost any value (more on this later), even an empty string, it’s unclear how the value of a shorthand property will be separated out into longhand properties that are used in the cascade later. For example, the auto used in the margin property above may turn out to be a top-and-bottom margin, a left-and-right margin, a top margin, a right margin, a bottom margin or a left margin — it all depends on the values of the custom properties around.

It’s questionable whether the code looks cleaner than the one from the previous example, but on a larger scale, it’s definitely more maintainable. Let’s try to simplify this code a bit now.

Notice that some values are repeated here. What if we try to merge duplicate variables together? Let’s consider the following alteration:

:root {
	--small-spacing: 0.5rem;
	--large-spacing: 1rem;
	--large-font-size: 2rem;
}

@media (min-width: 576px) {
	:root {
		--small-spacing: 1rem;
		--large-spacing: 2rem;
		--large-font-size: 3rem;
	}
}

.post {
	padding: var(--small-spacing) var(--large-spacing);
	margin: var(--small-spacing) auto  var(--large-spacing);
}

.heading {
	font-size: var(--large-font-size);
}

See the Pen
#3 Building responsive features with CSS custom properties
by Mikołaj (@mikolajdobrucki)
on CodePen.

It looks cleaner but is it actually better? Not necessarily. For the sake of flexibility and readability, this may not be the right solution in every case. We definitely shouldn’t merge some variables just because they accidentally turned out to hold the same values. Sometimes, as long as we’re doing this as a part of a well thought out system, it may help us simplify things and preserve consistency across the project. However, in other cases, such a manner may quickly prove to be confusing and problematic. Now, let’s take a look at yet another way we can approach this code.

Using CSS variables as multipliers

CSS custom properties are a fairly new feature to the modern web. One of the other awesome features that rolled out in the last years is the calc() function. It lets us perform real math operations in live CSS. In terms of the browser support, it’s supported in all browsers that support CSS custom properties.

calc() tends to play very nicely with CSS variables, making them even more powerful. This means we can both use calc() inside custom properties and custom properties inside calc()!

For example, the following CSS is perfectly valid:

:root {
	--size: 2;
}
	
.foo {
	--padding: calc(var(--size) * 1rem); /* 2 × 1rem = 2rem */
	padding: calc(var(--padding) * 2);   /* 2rem × 2 = 4rem */
}

Why does this matter to us and our responsive designs? It means that we can use a calc() function to alter CSS custom properties inside media queries. Let’s say we have a padding that should have a value of 5px on mobile and 10px on desktop. Instead of declaring this property two times, we can assign a variable to it and multiply it by two on larger screens:

:root {
	--padding: 1rem;
	--foo-padding: var(--padding);
}

@media (min-width: 576px) {                             
	:root {
		--foo-padding: calc(var(--padding) * 2);
	}
}

.foo {
	padding: var(--foo-padding);
}

Looks fine, however all the values (--padding, calc(--padding * 2)) are away from their declaration (padding). The syntax may also be pretty confusing with two different padding variables (--padding and --foo-padding) and an unclear relationship between them.

To make things a bit clearer, let’s try to code it the other way around:

:root {
	--multiplier: 1;
}

@media (min-width: 576px) {                             
	:root {
		--multiplier: 2;
	}
}

.foo {
	padding: calc(1rem * var(--multiplier));
}

This way, we accomplished the same computed output with much cleaner code! So, instead of using a variable for an initial value of the property (1rem), a variable was used to store a multiplier (1 on small screens and 2 on larger screens). It also allows us to use the --multiplier variable in other declarations. Let’s apply this technique to paddings and margins in our previous snippet:

:root {
	--multiplier: 1;
}

@media (min-width: 576px) {
	:root {
		--multiplier: 2;
	}
}

.post {
	padding: calc(.5rem * var(--multiplier))
						calc(1rem  * var(--multiplier));
	margin:  calc(.5rem * var(--multiplier))
						auto
						calc(1rem  * var(--multiplier));
}

Now, let’s try to implement the same approach with typography. First, we’ll add another heading to our designs:

<h1 class="heading-large">My Blog</h1>
<article class="post">
	<h2 class="heading-medium">Post's heading</h2>
	<p class="paragraph">
		Lorem ipsum dolor sit amet, consectetur adipisicing elit.
		Laudantium numquam adipisci recusandae officiis dolore tenetur,
		nisi, beatae praesentium, soluta ullam suscipit quas?
	</p>
</article>

With multiple text styles in place, we can use a variable to control their sizes too:

:root {
	--headings-multiplier: 1;
}

@media (min-width: 576px) {
	:root {
		--headings-multiplier: 3 / 2;
	}
}

.heading-medium {
	font-size: calc(2rem * var(--headings-multiplier))
}

.heading-large {
	font-size: calc(3rem * var(--headings-multiplier))
}

You may have noticed that 3 / 2 is not a valid CSS value at all. Why does it not cause an error then? The reason is that the syntax for CSS variables is extremely forgiving, which means almost anything can be assigned to a variable, even if it’s not a valid CSS value for any existing CSS property. Declared CSS custom properties are left almost entirely un-evaluated until they are computed by a user agent in certain declarations. So, once a variable is used in a value of some property, this value will turn valid or invalid at the computed-value time.

Oh, and another note about that last note: in case you’re wondering, I used a value of 3 / 2 simply to make a point. In real life, it would make more sense to write 1.5 instead to make the code more readable.

Now, let’s take a look at the finished live example combining everything that we discussed above:

See the Pen
#4 Building responsive features with CSS custom properties
by Mikołaj (@mikolajdobrucki)
on CodePen.

Again, I would never advocate for combining calc() with custom properties to make the code more concise as a general rule. But I can definitely imagine scenarios in which it helps to keep code more organized and maintainable. This approach also allows the weight of CSS to be significantly reduced, when it’s used wisely.

In terms of readability, we can consider it more readable once the underlying rule is understood. It helps to explain the logic and relations between values. On the other hand, some may see it as less readable, because it’s tough to instantly read what a property holds as a value without first doing the math. Also, using too many variables and calc() functions at once may unnecessarily obscure code and make it harder to understand, especially for juniors and front-end developers who are not focused on CSS.

Conclusion

Summing up, there’s a lot of ways to use CSS custom properties in responsive design, definitely not limited to the examples shown above. CSS variables can be used simply to separate the values from the designs. They can also be taken a step further and be combined with some math. None of the presented approaches is better nor worse than the others. The sensibility of using them depends on the case and context.

Now that you know how CSS custom properties can be used in responsive design, I hope you will find a way to introduce them in your own workflow. Next up, we’re going to look at approaches for using them in reusable components and modules, so stay tuned for the next post tomorrow!

The post Responsive Designs and CSS Custom Properties: Defining Variables and Breakpoints appeared first on CSS-Tricks.

Golden Pipeline Heritage Trail

The Golden Pipeline Heritage Trail is a historical drive trail through the heart of Western Australia, following the Goldfields Water Supply Scheme from Mundaring to Kalgoorlie. Custodians, National Trust WA, wanted a website to inspire more interest in the trail, driving appreciation and encouraging new visitors.

The post Golden Pipeline Heritage Trail appeared first on WeLoveWP.

Blogasm

Blogasm is a minimal, elegant, clean and responsive free WordPress blog theme with a pleasing design and minimalist color combination to emphasize your blog posts. Create your awesome blog for personal, fashion, lifestyle, food, travel, photography, portfolio, technology or any other types of blog sites. Built-in One-click demo importer option helps to get started quickly.

The post Blogasm appeared first on WeLoveWP.

3 Sided Cube

3 Sided Cube is an app development company with a focus on building mobile applications and digital software that has the power to change the world. Focussing on tech for good that has social impact has seen the UK based team work with brands and organisations including The Red Cross, Lush, Global Forest Watch and RNLI to make solutions that changes lives and saves lives all around the globe.

Their website is an example of unique navigation and use of scrolling that encourages the user to get lost in an infinite wormhole of content. A well thought out user journey allows visitors to digest comprehensive content and navigate a great blog design which makes interaction a joy.

Taking pride of place is a portfolio of impressive work which shows the quality and calibre of projects they work on, such as the worlds first blood tracking app and a platform that helped to save millions of lives through natural disaster tracking and alerting.

The post 3 Sided Cube appeared first on WeLoveWP.