Search This Blog

Thursday, April 7, 2011

Here is 1 more..................

A stylesheet consists of HTML elements, followed by rules defining how the elements will look. Font sizes, types, background colours, table borders are a few example of what would be defined in a typical stylesheet. The syntax of a stylesheet defines an HTML element followed by an attribute, which is then defined by a value. For instance, BODY is an HTML element, H1 is an attribute and color: black; is a value. 

Example : Simple inline stylesheet
<HTML>
<HEAD>
 <TITLE>Introduction to styles</TITLE>
<STYLE>
  H1, H2, H3
  {
  font-family: arial, trebuchet ms;
  text-decoration: underline;
  color: navy;
  }
</STYLE>
</HEAD>

<BODY>

 <H1>this is the h1 tag, modified using css</H1>
 <H2>this is the h2 tag, modified using css</H2>
 <H3>this is the h3 tag, modified using css</H3>

</BODY>
</HTML>
So, what is the above code doing? - Well, we have redefined the H1, H2 and H3 tags in an "inline" stylesheet, i.e. one that is hardcoded within the page, rather than a separate CSS document. We have declared how we want H1, H2 and H3 to look, and then we have used the tags to display some text, using our styles.

In this instance, we have grouped H1, H2 and H3 together. HTML elements can be redefined individually, or, as shown, as a group.

No comments:

Post a Comment