Click here to Skip to main content
12,068,108 members (40,470 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked

Intuitively Understandable HTML Content

, 27 Dec 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Making HTML intuitively understandable using CSS and JavaScript.


I want to introduce a few ways to use intuitively understandable user interface (IUUI) in JavaScript. What is IUUI? The answer is multilateral. One of the directions of IUUI is to emphasize important content and degrade the less valuable. I want to show you how to do it in the next examples where I'm using the I2UI JavaScript library.

Tags Cloud

Let's create a tags cloud for German states by population. A simple tag is presented by the name of the state and its font size, font weight, and opacity based on the state's population.

Here is a table of German state by population:

State Population
Baden 10717000
Bavaria 12444000
Berlin 3400000
Brandenburg 2568000
Bremen 663000
Hamburg 1735000
Hesse 6098000
Mecklenburg 1720000
Lower Saxony 8001000
North Rhine 18075000
Rhineland 4061000
Saarland 1056000
Saxony 4296000
Saxony-Anhalt 2494000
Schleswig 2829000
Thuringia 2355000

For start, need to add link to JavaScript library: 

 <script type="text/javascript" src=""></script>

 Then, we need to create an HTML structure for tags cloud:

    <span>Lower Saxony</span>
    <span>North Rhine</span>

Now, we can define a CSS which would belong to the lowest rate tag and highest rate tag. In other words, this is the range from one CSS selector to another CSS selector.


Now, we can indicate the CSS range and tags rates on HTML:

<div data-i2="css:['.fromStyle','.toStyle']">
    <span data-i2="rate:10717">Baden</span>
    <span data-i2="rate:12444">Bavaria</span>
    <span data-i2="rate:3400">Berlin</span>
    <span data-i2="rate:2568">Brandenburg</span>
    <span data-i2="rate:663">Bremen</span>
    <span data-i2="rate:1735">Hamburg</span>
    <span data-i2="rate:6098">Hesse</span>
    <span data-i2="rate:1720">Mecklenburg</span>
    <span data-i2="rate:8001">Lower Saxony</span>
    <span data-i2="rate:18075">North Rhine</span>
    <span data-i2="rate:4061">Rhineland</span>
    <span data-i2="rate:1056">Saarland</span>
    <span data-i2="rate:4296">Saxony</span>
    <span data-i2="rate:2494">Saxony-Anhalt</span>
    <span data-i2="rate:2829">Schleswig</span>
    <span data-i2="rate:2355">Thuringia</span>

As you can see, the tags rate is "thousands" of population. It doesn't matter what would be here, "thousands" or "numbers" of population. The main idea is to have the same ratio between rates.

In the end, we need to call the next JavaScript function which means "emphasize":


So, the tag with the smallest rate gets the fromStyle CSS properties, the tag with biggest rate gets the toStyle CSS properties. Thus the tags with rates between the above edges get CSS properties that depend on their rates.

Number Magnitude Emphasizing

When you take a look at the last table's population numbers, it's hard to recognize quickly the exact amount of people in each state. Now, let's observe an alternative way to present numbers based on their magnitude.

Let's redo the previous table into the following HTML code:

<table data-i2="css:[{fontSize:'10px',},{fontSize:'30px'}]">
       <td>Baden</td><td data-i2="number:10717000"></td> 
       <td>Bavaria</td><td data-i2="number:12444000"></td> 
       <td>Berlin</td><td data-i2="number:3400000"></td> 
       <td>Brandenburg</td><td data-i2="number:2568000"></td> 
       <td>Bremen</td><td data-i2="number:663000"></td> 
       <td>Hamburg</td><td data-i2="number:1735000"></td> 
       <td>Hesse</td><td data-i2="number:6098000"></td> 
       <td>Mecklenburg</td><td data-i2="number:1720000"></td> 
       <td>Lower Saxony</td><td data-i2="number:8001000"></td> 
       <td>North Rhine</td><td data-i2="number:18075000"></td> 
       <td>Rhineland</td><td data-i2="number:4061000"></td> 
       <td>Saarland</td><td data-i2="number:1056000"></td> 
       <td>Saxony</td><td data-i2="number:4296000"></td> 
       <td>Saxony-Anhalt</td><td data-i2="number:2494000"></td> 
       <td>Schleswig</td><td data-i2="number:2829000"></td> 
       <td>Thuringia</td><td data-i2="number:2355000"></td> 

Here is the result:

In this table, a quick look indicates that numbers are about millions, only Bremen has a few hundred thousand people. The highest number magnitudes are emphasized and the lowest are degraded. Thus, the user quickly detects the whole "picture" of the previous table.

Tag Group Emphasizing

What if we need to emphasize not just a simple tag, but a group of tags? Furthermore, let's imagine we have to represent each state with this HTML:


What if we need to display a block size, name's span, and population's span based on population? The issue is solved with "sets". Each "set" is a separate CSS range for the defined tags. Let's look at the example:

<div data-i2="css:{block:['.fromBlock','.toBlock'],name:['.fromName','.toName'],pop:['.fromPop','.toPop']}">
    <div data-i2="rate:10717,set:'block'">
        <span data-i2="rate:10717,set:'name'">Baden</span><br/>
        <span data-i2="number:10717000,set:'pop'"></span>
    <div data-i2="rate:12444,set:'block'">
        <span data-i2="rate:12444,set:'name'">Bavaria</span><br/>
        <span data-i2="number:12444000,set:'pop'"></span>
    <div data-i2="rate:3400,set:'block'">
        <span data-i2="rate:3400,set:'name'">Berlin</span><br/>
        <span data-i2="number:3400000,set:'pop'"></span>
    <div data-i2="rate:2568,set:'block'">
        <span data-i2="rate:2568,set:'name'">Brandenburg</span><br/>
        <span data-i2="number:2568000,set:'pop'"></span>
    <div data-i2="rate:663,set:'block'">
        <span data-i2="rate:663,set:'name'">Bremen</span>
        <span data-i2="number:663000,set:'pop'"></span>
    <div data-i2="rate:1735,set:'block'">
        <span data-i2="rate:1735,set:'name'">Hamburg</span><br/>
        <span data-i2="number:1735000,set:'pop'"></span>
    <div data-i2="rate:6098,set:'block'">
        <span data-i2="rate:6098,set:'name'">Hesse</span><br/>
        <span data-i2="number:6098000,set:'pop'"></span>
    <div data-i2="rate:1720,set:'block'">
        <span data-i2="rate:1720,set:'name'">Mecklenburg</span><br/>
        <span data-i2="number:1720000,set:'pop'"></span>
    <div data-i2="rate:8001,set:'block'">
        <span data-i2="rate:8001,set:'name'">Lower Saxony</span><br/>
        <span data-i2="number:8001000,set:'pop'"></span>
    <div data-i2="rate:18075,set:'block'">
        <span data-i2="rate:18075,set:'name'">North Rhine</span><br/>
        <span data-i2="number:18075000,set:'pop'"></span>
    <div data-i2="rate:4061,set:'block'">
        <span data-i2="rate:4061,set:'name'">Rhineland</span><br/>
        <span data-i2="number:4061000,set:'pop'"></span>
    <div data-i2="rate:1056,set:'block'">
        <span data-i2="rate:1056,set:'name'">Saarland</span><br/>
        <span data-i2="number:1056000,set:'pop'"></span>
    <div data-i2="rate:4296,set:'block'">
        <span data-i2="rate:4296,set:'name'">Saxony</span><br/>
        <span data-i2="number:4296000,set:'pop'"></span>
    <div data-i2="rate:2494,set:'block'">
        <span data-i2="rate:2494,set:'name'">Saxony-Anhalt</span><br/>
        <span data-i2="number:2494000,set:'pop'"></span>
    <div data-i2="rate:2829,set:'block'">
        <span data-i2="rate:2829,set:'name'">Schleswig</span><br/>
        <span data-i2="number:2829000,set:'pop'"></span>
    <div data-i2="rate:2355,set:'block'">
        <span data-i2="rate:2355,set:'name'">Thuringia</span><br/>
        <span data-i2="number:2355000,set:'pop'"></span>

Set is defined in the parent div tag. To indicate the tag that belongs to a specific set, we need to add the set property inside the tag attribute: data-i2.

Then, we need to specify the CSS ranges:

    border:1px solid #665E7C;
    border:10px solid #21007F;

As you may recognize, the first selector is about the "block" style, the others are about CSS ranges.

Let's see the result:

Awesome, the states with higher population number are emphasized with color brightness and sizes.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vadym Poberezhny
Software Developer
Ukraine Ukraine
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionNice. Pin
Marc Clifton27-Dec-13 4:54
protectorMarc Clifton27-Dec-13 4:54 
AnswerRe: Nice. Pin
Vadym Poberezhny27-Dec-13 10:45
memberVadym Poberezhny27-Dec-13 10:45 
GeneralMy vote is excellent Pin
AndyVGa26-Dec-13 9:46
memberAndyVGa26-Dec-13 9:46 
GeneralMy vote of 3 Pin
Antonio Ripa25-Dec-13 3:36
professionalAntonio Ripa25-Dec-13 3:36 
GeneralRe: My vote of 3 Pin
Vadym Poberezhny25-Dec-13 4:01
memberVadym Poberezhny25-Dec-13 4:01 
GeneralRe: My vote of 3 Pin
Antonio Ripa25-Dec-13 4:06
professionalAntonio Ripa25-Dec-13 4:06 
QuestionDoppelSaxony Pin
B. Clay "The Map Whisperer" Shannon24-Dec-13 9:19
professionalB. Clay "The Map Whisperer" Shannon24-Dec-13 9:19 
AnswerRe: DoppelSaxony Pin
Vadym Poberezhny24-Dec-13 10:21
memberVadym Poberezhny24-Dec-13 10:21 
GeneralRe: DoppelSaxony Pin
B. Clay "The Map Whisperer" Shannon24-Dec-13 11:37
professionalB. Clay "The Map Whisperer" Shannon24-Dec-13 11:37 
GeneralRe: DoppelSaxony Pin
Vadym Poberezhny24-Dec-13 11:46
memberVadym Poberezhny24-Dec-13 11:46 
GeneralRe: DoppelSaxony Pin
B. Clay "The Map Whisperer" Shannon24-Dec-13 11:53
professionalB. Clay "The Map Whisperer" Shannon24-Dec-13 11:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.160208.1 | Last Updated 27 Dec 2013
Article Copyright 2013 by Vadym Poberezhny
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid