Element Queries, Please

Michael Walsh
By Michael WalshPublished

Media queries are an essential tool for responsive web design, but they fall short in some situations.

Media queries give web designers the ability to vary the CSS styles (so how the website’s information is presented) depending on the device or viewport width. For example this allows us to increase font sizes when a website is viewed on a larger desktop computer screen.

The problem with media queries is that they don’t suit all situations. Often when taking an object-orientated approach to CSS (OOCSS) we might have a component, such as a contact or call me back form, that could exist in a narrow sidebar and also a wider content area. In both positions (sidebar and content area) the device/viewport is identical but the layout of the component needs to adapt to the narrower space when it’s in the sidebar. This is the situation where media queries are of no use as the device/viewport width has not changed only the width of the element.

So what do we need to resolve this? We need element or selector-based media queries that would allow us to adapt the CSS for a component based not upon the width of the device/viewport but rather the width of the element itself.

We use cookies to make this website work, to understand how it's used, and to measure our advertising. Find out more about cookies.

Cookie preferences

make an enquiry

Quick form · 3 steps · 1 min

How can we help?

Pick the closest match. We reply within one business day.

I am looking for

Website

New marketing website, microsite or redesign

E-commerce

Shopify store, new or rebuilt

Web application From £10,000 + VAT

Bespoke software and internal tools

AI implementation From £10,000 + VAT

Practical AI in your existing systems

Data visualisation From £10,000 + VAT

Dashboards and data pipelines

Migrations, hosting & support

Website migrations, web hosting and ongoing support

Something else / not sure yet

Let's talk it through

Prefer to talk?

Step 1 of 3

We'll be in touch within one business day to discuss your project. In the meantime, feel free to drop us a line at hello@enovate.co.uk if anything else comes up.

book directly

Book a discovery call with Michael

Michael Walsh, Founder & Managing Director. Pick a time that suits you, add your name and email, and the calendar invitation is yours.

Loading available times…

You can still book through the full calendar, or send us a message.

Times shown in . The calendar invitation lands in your inbox the moment you confirm.

Booking is handled by Calendly; see our privacy policy.

You're booked in

(). The calendar invitation is on its way to .

RescheduleCancel