CSS Outline, CSS Texts, CSS Fonts
Samir Rana
An outline is a line that is drawn around elements, OUTSIDE the
borders, to make the element "stand out".
Example: outline: #4CAF50 solid 10px;
Diagramatic Representation
CSS has the following outline properties:
outline-style
outline-color
outline-width
outline-offset
Outline
Note: Outline differs from borders! Unlike border, the outline is
drawn outside the element's border, and may overlap other content.
Also, the outline is NOT a part of the element's dimensions; the
element's total width and height is not affected by the width of the
outline.
CSS outline properties
The outline-style property specifies the style of the outline, and can have one of
the following values:
dotted - Defines a dotted outline
dashed - Defines a dashed outline
solid - Defines a solid outline
double - Defines a double outline
groove - Defines a 3D grooved outline
ridge - Defines a 3D ridged outline
inset - Defines a 3D inset outline
outset - Defines a 3D outset outline
none - Defines no outline
hidden - Defines a hidden outline
Outline Style
The outline-width property specifies the width of the
outline, and can have one of the following values:
thin (typically 1px)
medium (typically 3px)
thick (typically 5px)
A specific size (in px, pt, cm, em, etc)
CSS Outline Width
The outline-color property is used to set the color of the
outline.
The color can be set by:
name - specify a color name, like "red"
RGB - specify a RGB value, like "rgb(255,0,0)"
Hex - specify a hex value, like "#ff0000"
invert - performs a color inversion (which ensures that the
outline is visible, regardless of color background)
Outline Color
The outline property is a shorthand property for
setting the following individual outline properties:
outline-width
outline-style (required)
outline-color
The outline property is specified as one, two, or three
values from the list above. The order of the values
does not matter.
Outline - Shorthand property
The outline-offset property adds space between an outline and
the edge/border of an element. The space between an element
and its outline is transparent.
Outline Offset
Text Color
The color property is used to set the color of the text.
The color is specified by:
a color name - like "red"
a HEX value - like "#ff0000"
an RGB value - like "rgb(255,0,0)"
The default text color for a page is defined in the body
selector.
CSS Text
The text-align property is used to set the horizontal
alignment of a text.
A text can be left or right aligned, centered, or
justified.
Left alignment is default if text direction is left-to-
right, and right alignment is default if text direction
is right-to-left.
Text Alignment
When the text-align property is set to "justify",
each line is stretched so that every line has equal
width, and the left and right margins are straight
(like in magazines and newspapers):
The text-decoration property is used to set or remove
decorations from text.
The value text-decoration: none; is often used to
remove underlines from links:
Text Decoration
The text-transform property is used to specify
uppercase and lowercase letters in a text.
Itcan be used to turn everything into uppercase or
lowercase letters, or capitalize the first letter of
each word.
Text Transformation
Text Indentation
The text-indent property is used to specify the indentation of the
first line of a text.
Letter Spacing
The letter-spacing property is used to specify the space
between the characters in a text.
Line Height
The line-height property is used to specify the space between
lines
Word Spacing
The word-spacing property is used to specify the space
between the words in a text.
Text Spacing
The text-shadow property adds shadow to text.
In its simplest use, you only specify the horizontal
shadow (2px) and the vertical shadow (2px):
Example: text-shadow: 2px 2px;
Next, add a color (red) to the shadow:
Example: text-shadow: 2px 2px red;
Then, add a blur effect (5px) to the shadow:
Example: text-shadow: 2px 2px 5px red;
Text Shadow
The CSS font properties define the font family,
boldness, size, and the style of a text.
CSS Fonts
The font family of a text is set with the font-family property.
The font-family property should hold several font names as a
"fallback" system. If the browser does not support the first font, it tries
the next font, and so on.
Start with the font you want, and end with a generic family, to let the
browser pick a similar font in the generic family, if no other fonts are
available.
Note: If the name of a font family is more than one word, it must be in
quotation marks, like: "Times New Roman".
More than one font family is specified in a comma-separated list.
Font Family
The font-style property is mostly used to specify italic text.
This property has three values:
normal - The text is shown normally
italic - The text is shown in italics
oblique - The text is "leaning" (oblique is very similar to italic, but less
supported)
Font Weight
The font-weight property specifies the weight of a font:
Font Variant
The font-variant property specifies whether or not a text should be displayed in a
small-caps font.
In a small-caps font, all lowercase letters are converted to uppercase letters.
However, the converted uppercase letters appears in a smaller font size than the
original uppercase letters in the text.
CSS Font Style
The font-size property sets the size of the text.
The font-size value can be an absolute, or relative size.
Absolute size:
Sets the text to a specified size
Does not allow a user to change the text size in all browsers (bad for
accessibility reasons)
Absolute size is useful when the physical size of the output is known
Relative size:
Sets the size relative to surrounding elements
Allows a user to change the text size in browsers
Note: If you do not specify a font size, the default size for normal text, like
paragraphs, is 16px (16px=1em).
Font Size
Setting the text size with pixels gives you full control
over the text size:
Set Font Size With Pixels
To allow users to resize the text (in the browser
menu), many developers use em instead of pixels.
The em size unit is recommended by the W3C.
1em is equal to the current font size. The default text
size in browsers is 16px. So, the default size of 1em
is 16px.
The size can be calculated from pixels to em using
this formula: pixels/16=em
Set Font Size With Em
In the example above, the text size in em is the same
as the previous example in pixels. However, with the
em size, it is possible to adjust the text size in all
browsers.
Unfortunately, there is still a problem with older
versions of IE. The text becomes larger than it should
when made larger, and smaller than it should when
made smaller.
The solution that works in all browsers, is to set a
default font-size in percent for the <body> element:
Use a Combination of Percent and Em
Ifyou do not want to use any of the standard fonts in
HTML, you can use the Google Fonts API to add
hundreds of other fonts to your page.
Just add a stylesheet link and refer to a font family of
your choice.
Google Fonts
To shorten the code, it is also possible to specify all the individual
font properties in one property.
The font property is a shorthand property for:
font-style
font-variant
font-weight
font-size/line-height
font-family
Note: The font-size and font-family values are required. If one of
the other values is missing, their default value are used.
CSS Shorthand Font Property
Thank You