Css Tips
Css Tips
Css Tips
Sign in
TRENDING
Best drawing tablets
Graphic design
Web design
Adobe deals
UX course
When you purchase through links on our site, we may earn an affiliate commission. Here ’s how
it works.
One way to change it up is to draw inspiration from fields or areas that go beyond digital design.
Why not use print or editorial designs for your website? You can break old habits with new CSS
properties that open a new world of possibilities. You can utilise a decent website builder to
inspire you.
If you'd like more web design advice, see our guide to the perfect website layout, or brush up on
Atomic Design. Plus, here are the user experience tips you need to know.
In this article, we'll share some CSS tips that will help you break the mould in your website
layouts, with just a couple of lines of code.
01. Explore CSS blend modes
Duotone imagery and colouriser effects are some of the hottest web design trends. They are
widely popular across the web thanks to Spotify, which implements them cohesively. Now you
can finally stop creating multiple different coloured versions of your assets, and apply the effects
directly in the browser.
Using CSS blend modes is not only a great way to unify the look of the content across websites, it
also enables you to set different colour versions of an image, changing only one value in CSS: the
colour. There are 15 possible blend mode values, including screen, overlay, lighten and darken.
Ortiz Leon Architects uses blend modes to generate a duotone image background
(opens in new tab)
There are a couple of implementation methods, depending on the type of element you would like
to apply the effect to. For example, you can use background-image and background-colour set on
the container background-blend-mode: darken;, or create an overlay with pseudo-elements
(i.e. :before and :after) on the image wrapper in order to get a colourising effect.
To achieve a satisfying duotone effect, it’s recommended that you use a high-contrast black and
white image. You can do this by applying CSS filters to set greyscale and a high contrast level.
Bolden’s website has this great example of mix-blend-mode, which has been fully achieved in
CSS
(opens in new tab)
Another cool property is mix-blend-mode, which lets you blend content of the element with the
content or background of its direct parent. This works especially well on overlapped lettering. You
may ask why in this case we don’t just adjust opacity – the answer is simple: we can easily lose
the colour vividness using transparency only.
The era of images that can be edited directly in your web browser is coming, but we can’t forget
about browser compatibility – support is limited for blend modes at the moment. And for keeping
those images safe, make sure you explore your cloud storage options.
Note that unlike a typical raster image, SVG can be scaled or transformed without a significant
loss of quality.
img {
mask-image: url(‘mask.png’) linear-gradient(-45deg,
rgba(0,0,0,1) 20%, rgba(0,0,0,0) 50%);
mask-image: url(#masking); /*referencing to the element generated and defined in SVG code*/
}
It’s important to mention that Firefox supports only the latest one, so we need to use an inline
SVG mask element. What if we use a raster image with transparency levels? The transparent parts
of the image won’t be seen – so in other words, the opaque fragments will be displayed, hiding
other pieces.
Masking is particularly powerful because it enables you to apply the same properties to
background images, defining their position, size and repetition.
Here, the red background is the visible part, and text will emerge from behind the mountains (click
the image to see the final mask)
(opens in new tab)
One great use case for CSS masking is in articles that combine text and images. Irregular
containers and images are very popular in print, but tedious and time-consuming to implement on
the web. But thanks to masking, not any more!
You can also have fun using transparency levels to cut out part of animated images (eg. GIF files).
However, when using these properties, don’t forget about cross-browser support, and add vendor
prefixes.
The cool thing is that we can use shape functions and SVG as clip paths, which gives us a lot of
opportunities – for instance, we could animate them into morphing shapes. Check out this article
from Chris Coyier(opens in new tab) about creating transparent JPG using SVG clip path.
CSS websites
With clip path you can remove background from your image (click to see the full example)
(opens in new tab)
If you are wondering what the difference between clipping and masking is, then remember that
masks are images and clips are only vector paths. It's worth mentioning that masking will
consume more memory, as you're working with a full image so everything has to be done pixel by
pixel.
This is why it’s recommended that you use masks when you want a partial transparency effect; if
you want crisp edges, it’s best to use the clip paths.
So how does it work? Simply apply the following code to the given floating image or container:
Another possible value is the url() function. In this case, this enables the shape-outside property to
define an element shape based on the image. You might choose to use the url() function instead of
the polygon() when you have a particularly sophisticated graphic with many curves and points,
and you want the content to wrap around it smoothly.
Use DevTools to check how the shape you’ve designed for your text behaves (click the image to
see this example)
(opens in new tab)
If you’d like to create more room between your element and the content, use the shape-margin
property, which will act just like a margin. Shape functions can be animated, but only for defined
polygons – the url() function unfortunately is not able to be animated.
Browser support for shape-outside is limited at the moment, but keep your fingers crossed for its
fast implementation in other browsers.
This animated slideshow is from Aga’s presentation at CSSconf Nordic, and was created entirely
in HTML and SVG (click to see it in action)
(opens in new tab)
You may think that in some cases it’s easier to use raster images, however, SVG has one big
advantage over ordinary images. Words included in SVG are kept in the <text> tag and so remain
text, which makes it searchable, selectable and accessible. It also means you can edit it directly in
the code. However, we have to remember to embed the font face to be sure that the font will be
rendered.
Animating SVG with CSS is like animating any other element in HTML – it can be done with
transitions, transforms and keyframe animations. Once you’re familiar with the SVG code, the
rest is straightforward and very intuitive, because you basically do it just like you would in
HTML.
The coolest thing about SVG is that you can grab whatever part you want and make it come alive
with CSS animations. This means we can create some very interesting dynamic effects, not
necessarily using JavaScript. SVG has its own DOM API, so as a matter of fact the whole SVG
code can be easily inspected using DevTools, which I strongly recommend using while exploring
this topic.
This effect is very easy to code, and adds a strong visual accent to a website (click to see it live)
(opens in new tab)
The perfect example of how to do it in CSS only can be found on Captain Anonymous'
CodePen(opens in new tab), which presents skewed, animated text. One line of code does the
magic:
Mailchimp's homepage collages have been created using playful CSS properties
(opens in new tab)
The traditional approach is to simply attach raster images that have been prepared in a graphics
editor, but with the techniques I've discussed in this article, it is possible to create similar effects
by using CSS properties. You can even prepare collages that truly adjust to the web’s
requirements – and are scalable, animated and interactive.
I've prepared some examples using all these cool CSS properties, so you can see how they can be
combined to achieve a collage-like style on the web. Take a look at my examples(opens in new
tab).
The code that is included in the @supports block will be rendered only if these conditions are true,
otherwise the code has not been read by the browser. In a case where the browser doesn’t
understand @supports, it doesn’t generate a given part of the code either.
Although some properties may still experience problems with browsers’ compatibility (if you're
having a lot of problems, consider a more robust web hosting service), don’t hesitate to play with
them. Although browser support may be limited now, this will likely not be the case in the future.
It is just a matter of time.
Related articles:
11 CSS secrets you need to know in 2020
24 cool CSS animation examples to recreate
12 tips for amazing CSS animation
Get Weekly Tips and Inspiration
Your Email Address
Contact me with news and offers from other Future brands
Receive email from us on behalf of our trusted partners or sponsors
By submitting your information you agree to the Terms & Conditions(opens in new tab) and
Privacy Policy(opens in new tab) and are aged 16 or over.
Aga Naplocha
Aga is a designer and frontend coder at Adobe. She’s the co-founder of The Awwwesomes – a
non-profit organisation that teaches people to do awwwesome things on the web, and organises
coding workshops in Poland.
TOPICS
WEB DESIGN
CSS
INSPIRATION
MAGCONTENT
NETMAG
WEB DESIGN
RELATED ARTICLES
Sign up for our essential online UX design course: UX Design FoundationsSign up for our
essential online UX design course: UX Design FoundationsThis handy UX design cheatsheet is
invaluableThis handy UX design cheatsheet is invaluableGoogle reveals how it made Material
You in gorgeous design documentaryGoogle reveals how it made Material You in gorgeous design
documentaryUX research for beginners: 5 things to keep in mindUX research for beginners: 5
things to keep in mind
RECOMMENDED
The best drawing tablets: The best graphics tablets in M05 2023
How to make and sell an NFT
MOST READ
MOST SHARED
MTV logo
1
How the MTV logo captured the creative spirit of the 1980s
2
The latest iPhone 15 camera rumour is both good and bad news
3
Apple just dropped an unbelievable new iPhone feature like it's no big deal
4
This wild new TV is free to own – but at what price?
5
Wow, the original Nintendo logo was totally unrecognisable
DESIGN MAGAZINE SUBSCRIPTIONS
(opens in new tab)
●
Design Magazine Subscriptions
(opens in new tab)
Enjoy 12 months for £/$/€12
From
£12
(opens in new tab)
VIEW
(opens in new tab)
Creative Bloq is part of Future plc, an international media group and leading digital publisher.
Visit our corporate site(opens in new tab).
About us
(opens in new tab)
Contact Future's experts
(opens in new tab)
Terms and conditions
(opens in new tab)
Privacy policy
(opens in new tab)
Cookies policy
(opens in new tab)
Advertise with us
(opens in new tab)
Accessibility Statement
Careers
(opens in new tab)
© Future Publishing Limited Quay House, The Ambury, Bath BA1 1UA. All rights reserved.
England and Wales company registration number 2008885.