HtML UI Standardization and CSS override

It is important in large applications to standardize HTML elements styling in order to avoid UI inconsistencies. More importantly, standardizing styling of HTML tags reduces the need for using CSS (Cascading Style Sheets) for each HTML element separately, which mean less overhead and less time to initial page load.
Here is how it works:


1. Create a HtmlUtil.java class:

    public static String h1(String text)
    {
return "<h1 class='h1'>" + text + "";
    }
2. Create main.css:
h1,.h1 {
font-sizex-large;
font-weightbold;
padding4px;
margin4px;
}
h2,.h2 {
font-sizelarge;
colorgray;
padding4px;
margin5px;
}
...
3. Use HTML tag to override any CSS styling:
HTML panel = new HTML(HtmlUtil.h3("your text here..."));
Note that functions have HTML tag name as well as a CSS function name, in which you can use the latter to style Element like lable, VerticalPanel, etc.


As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles