Dharma Records

A record of Ānandajoti’s publication work.

Menu
  • Notices
  • Talks
  • Texts
  • Audio
  • Video
  • Photos
  • Ecology
  • Culture
  • Archives
  • About
Menu

Creating New Tags in Html5

Posted on January 17, 2017January 15, 2017 by Ānandajoti

I recently was looking for a solution to the excessive coding needed to add classes to html, which makes the document less readable than it need be.

Previous to this I have used some shortcuts by redefining set Html tags to do other jobs that I need, so for instance the emphasis tag foo serves for a declaration of what would otherwise need to be written as foo. This may not look like much but if you have a lot of spans that need to be marked it does in fact make it more readable.

em is defined in the css as:

em {color:darkred; font-style:normal; letter-spacing:1.25px;}

and give an inline presentation that highlights the metre markers with darkred, and looks like this:

Metre List

This solves some issues, but is also problematic in that we are not using tags semantically, and even more so because there are a very limited number of tags that can be redefined in this way.

Also for most of the cases where I use the metre class I want it to indent, so it is defined like this:

.metre {margin-left:2em; color:darkred; font-size:85%; line-height:100%; letter-spacing:1.25px;}

to give a presentation like this:

Verse 38

A New Solution

Warning, the following is not part of the Html5 standard, so if standards-compliance is your god, you can read it for interest and ignore its implementation.

The following was not discovered by me, I found it in Timothy Perez’ answer to a question posed on stackexchange:

Spans

Another way to achieve the same aim, is simply to declare a new “tag” in the css:

metre {margin-left:2em; color:darkred; font-size:85%; line-height:100%; letter-spacing:1.25px;} 

(Note the absence of the leading dot, which would define it as a class. Without the dot it becomes a tag.)

we can then transform this:

Verse 38

to this:

Verse 38

which to my mind is much more readable and therefore easier to maintain.

I have other classes I use regularly also, so by making a new tag like this

nmb {color:#7F9861; font-weight:normal; font-size:small;}

I can change this:

Dharma Collection

to this:

Dharma Collection

which gives a presentation looking like this:

Dharma Collection

Divisions

This solution will also work for divisions with the right coding. The way we normally declare a division is with a class to configure it, so:

.indent3 {margin-left:2em; margin-right:2em;}

with coding:

Division Class

gives:

Division Presentation

If we declare a tag, but with a little extra coding to make it display as a block:

b3 {display:block; margin-left:2em; margin-right:2em;}

then with coding:

Division Tag

We can achieve the same result.


To someone not involved in development this might not look like much of an improvement, but when you have tens of thousands of such spans and divs over a website, as I do, it makes everything so much easier to work with when reading the code.

Although not part of the Html5 standard, for many of us the fact that it works, cleans up the code, and is easy to implement recommends it.

I hope this will be of use to others as well. As far as I can see it works in all modern browsers. IE6 apparently doesn’t support it, but then all it will do is ignore the tag, and some presentation is lost.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

QR code

SHORTLINK

Donations

there are many expenses involved in the making of this website. Even a small donation really helps to maintain and expand the site.

Recent Posts

  • Dhammanīti, Dhamma Wisdom Published
  • Childers’ On Sandhi in Pali Published
  • Checkboxes for Long Works on Ancient Buddhist Texts
  • Dharma Storybooks on Photo Dharma
  • The Exalted Chapters, A Simplified Translation of the Udānavarga
  • Translation of the Sanskrit Udānavarga Published
  • The Lives of Inspiring Chinese Nuns
  • Five New Albums on Photo Dharma
  • Henri van Zeyst’s Contributions to the Sri Lankan Encyclopedia of Buddhism
  • The Reliefs of Buddhavanam eBook Published

Top Ten Tags

Buddha

Dhamma

Sangha

India

China

Indonesia

Thailand

Temples

Wisdom

Ethics

Other Websites

for my other websites please see my
LINKTREE

Sponsorship

 hosting sponsored by exabytes.my 

Random Posts

  • Aurangabad Caves, First Group
  • Facebook Comments: Dynamic Urls on Static Pages
  • Investiture of the Gods Reliefs on Photo Dharma
  • Pārāyanavagga, 2nd Revised Edition
  • Bhante Anandajoti: Precepts, Restraint and Practice
  • Arundhati Roy’s Speech: Come September
  • Photos of Gandhāran Works in the Musée Guimet, Paris
  • Second Edition of the Buddhist Wisdom Verses Published
  • The Beginnings of Buddhist Art by A. Foucher – V
  • Publication of the Revised Edition of the Great Chronicles of the Buddhas

Recent Posts

  • Dhammanīti, Dhamma Wisdom Published
  • Childers’ On Sandhi in Pali Published
  • Checkboxes for Long Works on Ancient Buddhist Texts
  • Dharma Storybooks on Photo Dharma
  • The Exalted Chapters, A Simplified Translation of the Udānavarga
  • Translation of the Sanskrit Udānavarga Published
  • The Lives of Inspiring Chinese Nuns
  • Five New Albums on Photo Dharma
  • Henri van Zeyst’s Contributions to the Sri Lankan Encyclopedia of Buddhism
  • The Reliefs of Buddhavanam eBook Published

Related Posts:

  • Writing Filenames into mp3 Tags with a Batch File
  • Virtual Desktops and Dual Monitors
  • Making short urls using javascript and a .htaccess file
  • Facebook Comments: Dynamic Urls on Static Pages
  • Problems with Wikipedia
  • Why the Buddha Suffered
  • Writing Filenames into JPEG Comments and Captions…
  • License Change on Photo Dharma Website
  • Uposatha Calendar 2013/2557
  • The Henri van Zeyst Archives
© 2026 Dharma Records | Powered by Minimalist Blog WordPress Theme