Suggestions for language usage when developing user interfaces


Defining anything will involve some subjectivity. The goal of semantic is not to create code that is free from prescription, but to create code that tends to avoid arbitrary decisions if a conventional choice presents itself.

The following are some guidelines which help avoid some common pitfalls in writing UI element definitions.

Neutral Base Form

In order to make UI components be able to exist in most websites, the prototype version of an element should be neutrally styled using greytones and neutral colors. This will allow other elements to be more robust giving other developers freedom to make decisions about color and style when adapting your element for their website.


All css code must live inside a namespace. By default all ui elements use the class "ui". This prevents rules from altering styles of other content in the page. This also helps differentiate between UI elements and parts of an element

Tags inside of a ui element do not need to be prefixed with ui. They can simple descend from the element.

/* incorrect */ .menu { } /* incorrect */ .ui.item { } /* correct */ { } .item { }


Try to use the most obvious names for classes. If you're not sure, prototype the element, then ask a friend or two what they would call it.

/* hmm */ .ginormous.ui.thingy { font-size: 1.5em; } /* better */ .large.ui.thingy { font-size: 1.5em; }


Classes should be defined in one word, if the concept cannot be reduced to a single word then consider factoring it into multiple sub classes

.attached.ui.thingy { position: relative; } .left.attached.ui.thingy { left: 0px; top: 50%; margin-top: -0.5em; } .right.attached.ui.thingy { right: 0px; top: 50%; margin-top: -0.5em }

Use real words

Abbreviations are useful for taking notes, but css definitions should attempt to use consistent, common language.

/* nope */ .ui.btn { } .ui.widget .cpttext { } /* good */ .ui.button { } .ui.widget .caption { }

Non prescriptive

Avoid requiring any specific tags in your definitions. This will allow developers to choose which tags they would like to use with an element.

Sometimes however it makes sense to allow for common tags to be used in place of classnames for brevity. Paragraph tags, links, labels, and tables may be useful to use in a UI element definition without classnames.

Be cautious though, for example, requiring a form definition to use a form tag limits a developers ability to nest form elements inside other forms. The same is true for anchor tags

/* hey how do you know this is the third heading? */ /* and what about all the other possible sizes? */ .ui.thingy h3 { } /* yay the developer can choose what type of heading tag to use */ .ui.thingy .header { }
/* wow this guy is going to have to do a lot of typing... */ .ui.table .cell { } /* this seems like a reasonable assumption, html is a bit strict about these things */ .ui.table td { }

Writing Variations

Same but not the same

Multiple elements may contain similar variations that function slightly different.

For example it may be useful for various elements to float left or right. At first it may seem most useful to write a helper class that floats all UI element types when given a certain class name, but the way which an element may be floated might vary depending on the type of element.

/* this element will default to floating left if any float is specified it will receive margins on its float relative to its size */ .ui.floated.widget, .ui.left.floated.widget { float: left; margin-right: 1em; } .ui.right.floated.widget { float: right; margin-left: 1em; } /* this will not receive margins when floated and will default to floating right */ .ui.floated.thingy, .ui.right.floated.thingy { float: right; } .ui.right.floated.thingy { float: left; }


Elements are often inverted to stand out on dark backgrounds. Consider creating a variation of your element defines how the element can invert its colors.

Keep in mind you might have to increase the contrast between shades of your element when inverting colors, its much easier to detect in a design between multiple shades of a light color than a dark one.

.ui.thingy { background-color: #FFFFFF; color: rgba(0, 0, 0, 0.7); } .ui.inverted.thingy { background-color: #222222; color: rgba(255, 255, 255, 0.7); }