HTML is very good at putting text in a web document. It is also effective for creating links from one document to another. However, HTML is not the best tool for formatting text or creating a look or style in a document. Currently we use Cascading Style Sheets (CSS) in order to style our documents and facilitate their ease of reading. CSS is a markup language that allows us to modify the look of various HTML tags as well as creating our own tags, classes, and other style elements.
As we know, HTML tags are in the form of a word or phrase surrounded by angle brackets. The following, for example, is an example of the paragraph tag.
<p>
This tag, and its corresponding closing tag allow us to separate text into paragraphs surrounded by blank lines.
</p>
This tag formats text into paragraphs but does not control the appearance of the text itself. If we simply use the paragraph tags and a line of text, for example, we get the sentence in whatever default font our browser has been assigned.
<p>This is a paragraph. It is separated from the preceding and following text by blank space. The font used is whatever default the browser chooses.</p>
If we want to designate a font style, color, size, or face we need a new technique to modify the paragraph. It is good to be able to apply the formatting to individual paragraphs rather than a blanket style to the entire page. If we chose, for example, to change the color of the text to red we could modify the paragraph tag with the following information.
<p style="color: RED;">This is a paragraph. It is separated from the preceding and following text by blank space. The font used in whatever default the browser chooses. </p>
The effect of adding the style element to the paragraph tag would result in the entire text of the paragraph being red.
This is a paragraph. It is separated from the preceding and following text by blank space. The font used is whatever default the browser chooses.
In order to add a style to a particular tag we place the style statement inside the angle brackets but after the text tag itself. Notice in the example above we follow the “p” in the paragraph tag with the word style and then the styling information surrounded by double quotes. We begin the style phrase with the property that we want to modify, in this case, color, followed by the modification we wish to make, in this case, changing the font color to red. The various properties and possibilities for any tag can be found at the W3 Schools web site. We do not have to modify the closing tag in any way.
Lets create another example. Suppose we wish to present the preceding paragraph above with the Times New Roman font face. We would modify our code fragment to the following:
<p style="color: RED; font-face: Times New Roman;">
This is a paragraph. It is separated from the preceding and following text by blank space. The font used in whatever default the browser chooses. </p>
We would see the following results in a browser:
This is a paragraph. It is separated from the preceding and following text by blank space. The font used in whatever default the browser chooses.
Notice that block above is displayed in red font color and also is in Times New Roman font.
We can modify any existing HTML tag. It is often easier to use class and ID designators in CSS but, when in Canvas, we are limited to inline styles. Even with inline styles we can control the look of our page down the the single letter.
This is a paragraph.Notice how we can change a single letter to a different color as well as a different size. We have the ability to control our page’s look to a very granular level. It is not usually necessary to modify to this level, however, it is nice to know we can.
So to summarize, we can use inline styles in order to modify the look of our page. We can change the size, face, weight, or color of the font. We can modify the alignment of the text or the way the text flows around an image. There is little we can not do with inline styles.