CSS: top, right, bottom, left

Do you ever forget what order sizes should go in CSS? The answer is top, right, bottom, left. This applies to styles like border, margin and padding. It is possible to use border-top, border-right, border-bottom, border-left and so on for the other styles, but it can be quicker (and saves a few bytes) to use a single CSS statement.

/* top; right; bottom; left */
border: 1em 0.1em 0.1em 0.1em;
/* top; right; bottom; left */
border: 0.1em 1em 0.1em 0.1em;
/* top; right; bottom; left */
border: 0.1em 0.1em 1em 0.1em;
/* top; right; bottom; left */
border: 0.1em 0.1em 0.1em 1em;

Shorthand

To make things even more concise, if the value is the same for all sides, or opposite sides, you can combine things as follows:

/* set all to the same value */
padding: 1em;

In the department of——, but it is better not to mention the department. The touchiest things in the world are departments, regiments, courts of justice, in a word, all branches of public service. Each individual nowadays thinks all society insulted in his person. Quite recently, a complaint was received from a district chief of police in which he plainly demonstrated that all the imperial institutions were going to the dogs, and that the Czar's sacred name was being taken in vain; and in proof he appended to the complaint a romance, in which the district chief of police is made to appear about once in every ten pages, and sometimes in a downright drunken condition. Therefore, in order to avoid all unpleasantness, it will be better to designate the department in question, as a certain department.

/* set the top/bottom to 1em and left/right respectively to 2em */
padding: 1em 2em;

So, in a certain department there was a certain official—not a very notable one, it must be allowed—short of stature, somewhat pock-marked, red-haired, and mole-eyed, with a bald forehead, wrinkled cheeks, and a complexion of the kind known as sanguine. The St. Petersburg climate was responsible for this. As for his official rank—with us Russians the rank comes first—he was what is called a perpetual titular councillor, over which, as is well known, some writers make merry and crack their jokes, obeying the praiseworthy custom of attacking those who cannot bite back.

/* set the top to 1em, the left/right to 2em and the bottom to 3em */
padding: 1em 2em 3em;

His family name was Bashmachkin. This name is evidently derived from bashmak (shoe); but, when, at what time, and in what manner, is not known. His father and grandfather, and all the Bashmachkins, always wore boots, which were resoled two or three times a year. His name was Akaky Akakiyevich. It may strike the reader as rather singular and far-fetched; but he may rest assured that it was by no means far-fetched, and that the circumstances were such that it would have been impossible to give him any other.

This was how it came about.

/* set each value inidivually */
padding: 1em 2em 3em 4em;

Akaky Akakiyevich was born, if my memory fails me not, in the evening on the 23rd of March. His mother, the wife of a Government official, and a very fine woman, made all due arrangements for having the child baptised. She was lying on the bed opposite the door; on her right stood the godfather, Ivan Ivanovich Eroshkin, a most estimable man, who served as the head clerk of the senate; and the godmother, Arina Semyonovna Bielobrinshkova, the wife of an officer of the quarter, and a woman of rare virtues. They offered the mother her choice of three names, Mokiya, Sossiya, or that the child should be called after the martyr Khozdazat. "No," said the good woman, "all those names are poor." In order to please her, they opened the calendar at another place; three more names appeared, Triphily, Dula, and Varakhasy. "This is awful," said the old woman. "What names! I truly never heard the like. I might have put up with Varadat or Varukh, but not Triphily and Varakhasy!" They turned to another page and found Pavsikakhy and Vakhtisy. "Now I see," said the old woman, "that it is plainly fate. And since such is the case, it will be better to name him after his father. His father's name was Akaky, so let his son's name be Akaky too." In this manner he became Akaky Akakiyevich. They christened the child, whereat he wept, and made a grimace, as though he foresaw that he was to be a titular councillor.

Text from Gogol’s The Cloak via Project Gutenberg.

Tags: