Thursday, 5 February 2015

USING CASCADING STYLE SHEETS

 Earlier, I mentioned cascading style sheets as a way you could control the look and feel of your pages. Styles are a way to control how the browser renders HTML tag (or elements, as they’re called in standards documents) for example, in today’s lesson, I’ve used the <h1> tag a number of times. Most browsers print text enclosed inside an <h1> tag in a large, bold race font and leave some white space after the heading before printing something else. Using cascading style sheets, you can tell the browser to render the <h1> tag differently that it normally would. CSS provides a lot of flexibility in how you can alter the appearance of any type of element, and the styles can be applied in a number of different ways.
The advantage of CSS is that it can be used at varying levels of specificity. For example, you can put al your styles into a separate file, and link to that file from your web page. That way, if you want to change the appearance of your site, you a can simply edit you CSS file and make changes that span every page that thinks to you r style sheet. Or, if you prefer, tyou can include styles at the top of your page so that they apply only to that page. You can also include styles inside the tags themselves using the style attribute (which I’ll discuss in lesson 9, “creating layouts with CSS”.
You can also control the specificity of the styles you create based on how you define them. For example, you can write rules that apply to all tags of a specific type such as all <h1> elements. Or you can specify classes for your elements and then write rules that apply only to members of that class. For example, you could create a class called head line and then make all <h1> elements in the head line class red. You can also write rules that apply to specific elements by assigning them a particular identifier and writing rules that apply to that identifier.
One thing you’ll find as you progress through the book is that a CSS can serve as a replacement for many common tags. As I describe various tags, I’ll explain how the same effects can be achieved using CSS instead. Generally, the flexibility of CSS means you should user HTML to describe the structure of pages and CSS to define their appearance, the coverage of CSS in this book culminates with lesson 9., which explains how to use CSS to manage the entire layout of the page, or even the entire layout of a site.
INCLUDING SYTLES IN TAGS.
You’ve already seen how HTML pages are created using tags. I want to stop briefly and discuss attributes as well. An attribute is an additional bit of information that somehow affects the behavior of a tag. Attributes are included inside the opening tag in a pair. Here’s an example.
<tag attribute=”value”>


No comments:

Post a Comment