Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using HTML5 details element in printing

Tags:

css

printing

We use the HTML5 element <details> to offer simple show/hide functionality.

This works fine on-screen but in print, any <details> elements not already open on screen are hidden when printing.

I thought this would work:

@media print {
    details { display:block !important }
}

but it doesn't.

Obviously, this represents a negative print user experience - has anybody managed to get this to work for printing?

Thanks

like image 467
neil Avatar asked Oct 21 '25 22:10

neil


1 Answers

As at 2024-11-15 current CSS Working Group (csswg) proposal for issue 2084 Draft added for pseudo-element ::details-content

Draft added for pseudo state :closed and :open but minimal browser support

details[open]::details-content { display: contents; }

like image 111
dj.cowan Avatar answered Oct 23 '25 12:10

dj.cowan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!