Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FireBlade's avatar

Tailwind CSS hidden not working with all responsive breakpoints

This class is not working:

<img class="md:hidden" src="{{asset('storage/img/'.$pdf->filename)}}" alt="{{$pdf->filename}}">

yet this one is working:

<img class="hidden" src="{{asset('storage/img/'.$pdf->filename)}}" alt="{{$pdf->filename}}">

In fact all breakpoints are not working with the hidden utility

0 likes
10 replies
Snapey's avatar

are you building the css every time?

Tray2's avatar

@FireBlade You should run npm run dev in the root of your project, unless you are using tailwind from a cdn.

jekinney's avatar

Resize your screen or use the dev tools to set as medium size to verify it is. If not post back and let us know.

Should display at large and I believe (not 100% sure and to lazy to go verify) that it may display at "small" size

gych's avatar

@jekinney When using md:hidden on an element, the element will only display at sizes smaller than md (768px)

gych's avatar

@Snapey No it will display at sizes greater than md (768px) if you use max-md:hidden

Snapey's avatar

@gych no thats not right for tailwind

hidden is applied at all breakpoints

md:hidden is applied at medium and greater

From the docs in responsive section;

By default, the outer div is display: block, but by adding the md:flex utility, it becomes display: flex on medium screens and larger.

gych's avatar

@Snapey Yes and that matches exactly what I said:

When using md:hidden on an element, the element will only display at sizes smaller than md (768px)

I never said that the hidden class is only applied at sizes smaller than md when using md:hidden

Please or to participate in this conversation.