This small snippet allows you to override a default heading for a callout box using a data attribute and the CSS cascade.
CSS
How to overlap elements with HTML and CSS (Grid) only
Thanks to CSS grid, overlapping elements on a web page is easy and reliable, unlike the earlier methods that were fraught with pitfalls. Here’s a short screencast that shows you how. Below the video are an image of the final outcome and the HTML and CSS code.
CSS Pseudo-classes Trick Using :has, :not, and :hover
Suppose you have a 3×3 grid of cards or images. Further suppose that when you hover over any one of the 9 elements, you want to make that element stand out by affecting how all the other elements behave. In the example in this article, the non-hovered elements (a) get smaller; (b) change background colors; and (c) get blurred. And all of these effects take place gradually, with CSS transitions.
Background image opacity: How to alter without affecting foreground content
You cannot alter the opacity of a background image without affecting foreground content. Like me, you may have learned this the hard way when you first tried to add some heading text over a background image in a page hero. Thanks to Jessica Chan (aka Coder Coder on YouTube and CodePen), we have two excellent solutions.
Create Accordions & Toggles in WordPress with HTML and CSS Only
Many WordPress themes have blocks or patterns for accordions and toggles. Also, there are more block addons for accordions and toggles than you can shake a stick at. But you don’t need special blocks to create accordions or toggles, and I strongly encourage you to roll your own, using either the classic editor or the Custom HTML Gutenberg block.
Responsive Tables with Minimal CSS
HTML tables have been around since the beginning of the web, when they were our only layout tool. Nowadays, we have much better layout tools (like Flexbox and CSS Grid), but HTML tables still serve a purpose: they remain one of the best tools HTML offers for presenting structured information in a matrix of rows and columns — except when the user’s device is too small for the content to fit.
Here’s how to make tables mobile responsive with just 12 lines of CSS markup.
Create a Membership Card for a MemberPress Site
A few days ago, someone in the “MemberPress Unofficial User Group” on Facebook asked how he could offer his website members a membership card that can be accessed on a phone to prove membership. It so happens I created such a membership card for one of my client websites, using the MemberPress Account Nav Tabs addon, a few standard MemberPress shortcodes, a bit of CSS, and one custom shortcode. This article documents that solution.
Adding Taxonomies to the WordPress Body Class
Sometimes it’s desirable to render WordPress posts or pages distinctively based on the categories or tags assigned to them. This post shows how that’s done.
Make a Poster Graphic with HTML and CSS Using Grid Template Areas — and NO Graphics Program
A client asked me to create an improved version of a poster graphic to be embedded in a marketing email. The main problems with the original graphic were color contrast and readability (too much prose text where bullet lists would be better). My initial approach was to open the original PDF in Adobe Illustrator and make the modifications there. However, the file’s layer palette was a hot mess of nested groups and clipping paths. Abandoning Illustrator, I opted to create the new graphic with HTML and CSS — specifically, CSS Grid and Grid Template Areas. This blog post shows how I did it.
Avoid Direct Styling; Use CSS Instead
In this article I urge people to avoid the use of direct styling and instead rely on CSS for defining how the elements of a page or post should appear. I explain the downsides of direct styling and the advantages of CSS. Although, CSS is a huge topic, you don’t have to be an expert in CSS to use it in some basic and helpful ways.