RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

HTML Details Tag WordPress Shortcode

HTML Details Tag WordPress Shortcode

The HTML <details> tag is a lesser-used HTML tags which often negates the need to use fancy-pants JavaScript to return 'hidden' content. The website we provide mortgage brokers is packed with shortcodes and Elementor widgets that makes the creation of dynamic website content easy, and despite providing a number of shortcodes for fancy content reveals, the details tag is easy to use and every bit as functional as fancy alternatives. This article provides a basic introduction to the shortcode, and we provide a download of the necessary code for those that wish to implement the feature themselves.

Mozilla standards defines the details tag as one that ...creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label must be provided using the <summary> element.

The Result

The basic result is returned via the shortcode of [bm_details title="Title"]My Text[/bm_details]. The result:

This is a Details Title
This is the text returned when the details block is selected. This text may be formatted in any manner of your choosing, and it may include shortcode content.

In the second example we'll use a mouseover feature to show the blind when you move your cursor over the details text. We'll also apply some inline CSS with the attribute of title_css="font-weight: normal; border: none;. The result:

This is Mouseover Title Text
This text will show when a user moves their mouse over the details panel. Shostrcode is also supported - in this case we're showing a YouTube video with the relevant shortcode.

It's obviously not entirely suitable for video as it requires the user maintain their cursor over the panel while they're watching (we're pretty sure we can listen for the YouTube event and keep the panel open - we just haven't figured it out yet).

The HTML

As per specifications, you can create the summary section with naked HTML. Use the following CSS and HTML.

1
details {
2
    border: 1px solid #aaa;
3
    border-radius: 4px;
4
    padding: 0.5em 0.5em 0;
5
}
6
 
7
summary {
8
    font-weight: bold;
9
    margin: -0.5em -0.5em 0;
10
    padding: 0.5em;
11
}
12
 
13
details[open] {
14
    padding: 0.5em;
15
}
16
 
17
details[open] summary {
18
    border-bottom: 1px solid #aaa;
19
    margin-bottom: 0.5em;
20
}

The following HTML returns the result:

1
<details>
2
<summary>Details</summary>
3
 
4
Something small enough to escape casual notice.
5
</details>

To open the summary panel by default, use <details open> To apply a custom 'button', use the following CSS (in this case we're using a Font Awesome chevron):

1
summary {
2
 display: block;
3
}
4
 
5
summary::before {
6
 margin-left: 1ch;
7
 display: inline-block;
8
 transition: 0.2s;
9
 content: '\203A';
10
}
11
 
12
details[open] summary::before {
13
 transform: rotate(90deg);
14
}

The Shortcode

The shortcode function should generally be applied in WordPress simply because it enables you to globally alter functionality and style in the future without having to edit every occurrence of the tag.

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

1
<?php 
2
/*
3
 HTML Details Tag WordPress Shortcode
4
 https://www.beliefmedia.com.au/details-tag-shortcode
5
*/
6
 
7
function bmdetails($atts, $content = null) {
8
 
9
 $atts = shortcode_atts(array(
10
 
11
  'title' => 'Your Title Here',
12
  'open' => false,
13
  'title_css' => '',
14
  'text_css' => '',
15
  'mouseover' => false,
16
 
17
 ), $atts);
18
 
19
 $r = '';
20
 $open = ($atts['open'] !== false) ? ' open' : '';
21
 $c = substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", 4)), 0, 4);
22
 
23
 if ($atts['mouseover'] !== false) {
24
 
25
  $r .= '<script>jQuery(function() {
26
   jQuery(\'#details_' . $c . '\').on(\'mouseover\', function() {
27
    jQuery(this).attr(\'open\', true);
28
   }).on(\'mouseout\', function() {
29
    jQuery(this).attr(\'open\', false);
30
   })
31
  });</script>';
32
 }
33
 
34
 $r .= '
35
<details id="details_' . $c . '"' . $open . '>
36
<summary style="' . $atts['title_css'] . '">' . $atts['title'] . '</summary>
37
<div class="text" style="' . $atts['text_css'] . '">' . do_shortcode($content) . '</div>
38
</details>
39
 
40
';
41
 
42
 return $r;
43
}
44
add_shortcode('bm_details', 'bmdetails');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

CSS will be required in your custom function's CSS file as follows:

1
details {
2
 border: 1px solid #aaa;
3
 border-radius: 4px;
4
 padding: 0.5em 0.5em 0;
5
}
6
 
7
summary {
8
 font-weight: bold;
9
 margin: -0.5em 1.0em 0;
10
 padding: 0.5em;
11
}
12
 
13
details[open] {
14
 padding: 0.5em;
15
}
16
 
17
details[open] summary {
18
 border-bottom: 1px solid #aaa;
19
 margin-bottom: 0.5em;
20
}
21
 
22
details .text {
23
 margin-left: 20px;
24
 font-weight: normal;
25
 font-size: 0.9em;
26
 margin-top: 15px;
27
}

In the downloadable version we've wrapped the result in paragraph tags.

Shortcode Attributes

Standard shortcode attributes are as follows:

title

The title of the panel (summary) - title="Your Title in Here".

open

To render the details panel open by default, use open="1".

title_css

Title CSS is applied to the summary (title) section. As per our example above, use title_css="font-weight: normal; border: none; (the CSS is applied inline).

text_css

The CSS applied to the reveal text. The CSS is applied inline and simply overrides the default CSS. For example: text_css="line-height: 1.0; color: #000000;".

mouseover

If you wish to open the details panel on mouseover use mouseover="1".

By default the feature will render as per the first example.

Yabber Blocks Integration

Clients may render content by referencing a Yabber block. To do so, reference the numeric block value in your shortcode between the [bm_details]. For example, [bm_details title="Example Block Content"]63624[/bm_details] (in this case we've referenced entirely irrelevant content relating to Scrollable). The result:

Example Block Content

This is an example of a Scrollable window. In this particular example we've used a smaller font size and line height but in most cases the font will default to that used on your page. We've also applied a border and a redirect checkbox (it redirects back to this page but the expectation is that you'll redirect to a new page or form).

All elements of this Scrollable window are customisable, and not unlike any other Block element, media and shortcodes may be applied.

Scrollable was introduced for a number of reasons. First and foremost it's just a funky tool that's available to you, but it was also a compliance consideration. In talks with a group quite recently they indicated that they were obligated to provide an entry disclaimer whenever an online application was commenced.

The Scrollable window may be dragged into any position of your page with our Elementor block or via the use of shortcode.

The scroll handle and background may also be customised.

There are other Yabber content tools, such as a facility to return specific lender data, products, and information, meaning that your blind content will always be up-to-date.

Conclusion

The details shortcode is just another way in which to render content or Yabber blocks. The reality is that you'll pick one specific way in which to return content and then generally stick with it.

A significant reason for inclusion of this feature is that we can return content in the manner described by way of our article program. Our Yabber and partner plugin supports a range of tools to make 'generic' articles more dynamic, and the details shortcode provides us with more options.

For more information on various content features or Block options, consider the articles below.

Given that website and business content is ridiculously important, and since very few brokers assign the necessary time to improve upon their digital footprint, we decided to improve upon Yabber's content modules with a program we're calling . The Contentus module is a parent module that'll support our existing suite of tools that'll allow you .. [ Learn More ]

Scrollable is a content tool we've introduced as part of our '' module, and downline to Yabber's parent . Scrollable simply allows you to include blocks of content in a scrollable window for those cases where you choose to contain large amounts of text in a smaller contained area. An option to render a checkbox .. [ Learn More ]

In a previous article we introduced Yabber's ' module, and how the system is used as part of your simplified content creation strategy. If you're unfamiliar with the Block concept, and in brief, they're simply a block of content that is created on Yabber and then referenced anywhere on your website. Changes made to the .. [ Learn More ]

Download

Download the shortcode and CSS below. If you're not a client, you should have our custom functions plugin installed.


Title: Details Tag Shortcode
Description: The 'details' tags creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label must be provided using the 'summary' element. The shortcode makes the addition of the feature easy.
  Download • Version 0.1, 1.3K, zip, Category: WordPress Shortcodes
  Featured Image: Sydney panorama from Town Hall clock tower, George Street Sydney, 1873. From the Sydney archives, One of nine photos making up a panorama. View south east along George Street towards Central and Surry Hills, showing St Andrews Cathedral at bottom right, Belmore Park, the Benevolent Asylum, Devonshire Cemetery and the Exhibition Building in distance in Prince Alfred Park. Signs on buildings include Melbourne Boot Comp, Sydney Coach Building Company, Forrester, Condell Boots (Robert Condell, boot warehouse, 588 George Street), EF Flanagan (Edward Flanagan, stationery, book seller, 594 George Street), Kangaroo Hotel (Alexander Yeend, 471 George Street, site of Bank of NSW), TJ Brown, Engineer (99 Bathurst Street) & Lawlers (John Lawler, 517 George Street). In 1873, Sydney photographer Francis W. Robinson undertook a perilous ascent of the clock tower of Sydney Town Hall, then nearing completion as the tallest structure in Sydney. His images record the Sydney skyline of that time. [ View Image ]

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment