Text
Below are some of the major properties:
Font properties are used to enhance the font which is in a form of text
- font-family – specify a family of fonts (e.g., font-family: Arial, Helvetica, san-serif)
- font-style – set the font style (values: italic, oblique, or normal). Oblique is a computerized rendering of a normal font in which each letter is inclined a certain number of degrees to the right similar to italic. Example: h1 {font-style:italic;}
- font-variant – set normal or small-caps. (values: small-caps, normal) Example: h1 {font-variant:small-caps;}
- font-weight – refer to the font thickness that make text bold in varying degrees. (values: 100-900, lighter, normal, bold and bolder). (e.g., a {font-weight:bold;} ).
- font-size – specify the type size (e.g., font-size: 24px)
CAUTION: Do not add a space between the number and the unit of measurement. (e.g., font-size: 24 px will NOT work)
- line-height – specify space between adjacent lines of text in a paragraph. Known as leading in the print community. (values: any numerical value).
NOTE: Line height greater than the text height is shared both below and above text. For line-height (1.4) select multiple as the unit of measurement to avoid bugs in some browsers when certain units of measurements are set on line height. When the value multiple is used, notice there is no unit of measurement because it is a multiplier of the current font size (e.g., 1.5 x current font size).
Text properties are used to enhance the readability and appearance of text on a page.
- color – set the font text color (e.g., any hexadecimal or named value) Example: p {color: #FF0000;} or p { color: red;}
- text-align – control horizontal alignment of text content (values: left, right, center and justify). Example p {text-align:left;}(left, right, center, and justify)
- text-decoration – creates underline, over-line, and line-through effects on text element. (values: underline, overline, line-through)
- text-indent – applies indent to the first line of text in a paragraph or other text elements. (values: any negative/positive value). Example: p {text-indent:5em;} Using a negative value will create a hanging indent. It is best practice to set indents and related margins in ems so that the indent remains proportional.
- text-transform – set the case of the text (values: uppercase, lowercase, capitalize, none) Example: p {text-transform:uppercase;}
NOTE: The uppercase option is useful to ensure that the text is ALWAYS in ALL CAPS even though it may not have been written in all caps. For example, the title Welcome to my website will always be rendered as WELCOME TO MY WEBSITE even though the HTML code is not in all caps.
TIP: It is best practice to have links INSIDE a page to have underline and to remove the underline when the mouse hover over it for better readability.
- underline
- line-through
- overline (need to be viewed in a browser)
- blink (need to be viewed in a browser)
- letter-spacing – add or remove space between LETTERS of any text element. (values: any negative/positive value) Example: p {letter-spacing:.3em;} Known as kerning in the print community). It is best practice to set indents and related margins in ems so that the indent remains proportional. A positive value will add spaces (e.g., T h i s i s a s e n t e n c e.)
TIP: Best used for short headlines and movie titles.
- word-spacing – add or remove space between WORDS. (values: any negative/positive value) Example: p {word-spacing:.2em;} A positive value will add spaces (e.g., This is a sentence.) and a negative value will remove spaces (e.g. Thisisasentence.)
- vertical-align – control the vertical alignment of an element. (values: value, sub, sup, top, middle, bottom, etc.). Typically used to create subscript (sub) and superscript (super) which is typically used for copyright, trademark symbols, etc. (e.g., © ® ™) Examples: H20 , 52nd Street
TIP: It is best practice to use text-size and vertical-align together using descendant selectors that will be discussed later to create super/subscripts for better results:
p.custom sub {vertical-align: -.25em; font-size:65%;}
p.custom sup {vertical-align:.6em;font-size:65%;}
p.customsmall {vertical-align:1em; font-size:.8em;}
TIP: The <sub> and <sup> tags don't change the size of the text. Changing the size to 75% is a good start for these properties.
- list:
- list-style-type – select bullet type (values: disc, circle, square, decimal [1,2,3], lower-roman [i, ii, iii], upper-roman [I,II, III], lower-alpha [a,b,c], upper-alpha [A,B,C] and none)
- list-style-position – control placement relative to <li> tags (values: inside or outside)
- list-style-image – select a small image that can be used as bullets instead of the default bullets (listed above)
- whitespace – control how the browser displays extra white space (e.g., spaces, tabs, returns, etc.). (values: normal, pre and nowrap). The pre property works like the <pre> tag. The nowrap property prevents line breaking.
Text-shadow: (Similar to text shadow)
- h-shadow
- v-shadow
- blur
- color
EXAMPLES:
Below are examples of some of the most common properties used in the Text section:
- In Design View, select the first div and then in the CSS Designer panel, select the Text icon () at the top of the panel.
- Set the following highlighted values:
- CHECK POINT: Save the file and preview it in a browser. You should see the text has been formatted with the highlighted styles:
- Repeat the previous three steps for the second div:
TIP: You could COPY the specified properties from the #myBox2 and paste into #myBox1 or you could CUT the specified properties out of #myBox2 and create a new group selector for by with those selectors (e.g., #myBox1, #myBox2 {paste specified properties here}):
- In Design View, select the first div and then in the CSS Designer panel, select the Text icon () at the top of the panel.
- Set the following highlighted values:
- CHECK POINT: Save the file and preview it in a browser. You should see the text has been formatted with the highlighted styles:
- Repeat the previous three steps for the second div: