A Look at New and Changed Formatting HTML5 Elements
Application Security Testing: An Integral Part of DevOps
The HTML5 specification has made number of changes to support better formatting of text in web pages. In this article, we will take a look at some of the new and changed markup elements which deal with formatting.
Let’s start with the new markup element – wbr.
WBR Markup Element
The HTML5 specification describes the wbr element as an element which represents a line-break opportunity.
The wbr markup element is used to decorate text to help the browser to identify the location with it cab break to provide a sensible experience to the web user (instead of rendering the text using scroll bars)
The wbr markup element is a void element, which implies that it must have a start tag but must not have an end tag.
The wbr markup element can be contained in any phrasing element and supports all global attributes.
Since it is a void element, no contents are permitted.
Here is a simple HTML5 web page which shows wbr markup element in action.
<p>Demo showing wbr markup element in action</p>
When the above code is rendered in browser, it shows that word contiguously.
Now, when we reduce the window size of the Google Chrome browser, you can see that the long word is broken into 2 lines at the location we tagged as “wbr”.
We can see above that the long word was broken into two lines and provides a reasonable experience to the reader.
Small markup element
The small markup element is not new to HTML5, but has changed a bit in the latest version. In the prior versions, it was defined only in presentational terms. With HTML5, small markup element is officially tagged as the markup element to be used to represent text which is usually called the “fine print” or “small print”.
The small markup element is a phrasing content and needs both the start tag as well as the end tag.
Here is a sample HTML5 code snippet which shows how small markup element works.
<p>Demo showing small markup element in action</p>
When this is rendered in browser, you can see the size of “Copyright 2014” appears as fineprint.
CITE Markup Element
Like the small markup element, the cite markup element is not new to HTML5. Cite markup element is used to represent the cited title of a work. With previous versions of HTML, it could be used to mark up name of person, but that is no longer the case. Now, it is specifically targeted to represent the title of a work (work could be book, paper, essay, poem, score, song, script, film, TV show, game, sculpture, painting, theatre production, play, opera, musical, exhibition, legal case report, or other such work).
Cite markup element allows phrasing content to be included and requires both a start tag and an end tag. It can be contained in any phrasing element.
Here is a sample HTML5 code snippet which shows the cite markup in action
<p>Demo showing cite markup element in action</p>
<p><cite>HTML Goodies</cite> by Fantastic WebDevs</p>
When the above HTML web page is rendered in Google Chrome, it shows the cited text in italics.
In this article, we took a look at the wbr markup element, which is new in HTML5, as well as some updated formatting elements like small and cite. I hope you have found this information useful.
About the author
Vipul Patel is a Program Manager currently working at Amazon Corporation. He has formerly worked at Microsoft in the Lync team and in the .NET team (in the Base Class libraries and the Debugging and Profiling team). He can be reached at email@example.com
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...