Understanding CSS: - HTML Selector
Understanding CSS: - HTML Selector
Introduction
HTML lacks versatility when it comes to presenting various kinds of content that Web designers have come to demand. In fact HTML was designed to allow authors to define the structure of a document for distribution on a network such as the Web. Its nature is to show how the page should be organized. The W3C designed Cascading Style Sheets to fill the design void of straight HTML. Rather than adding more tags to set the appearance and style, CSS works directly with existing HTML tags to them how to behave.
What is a Style?
Styles collect all the different properties, such as: Font family Size Color Position Background Borders Spacing Lists
that can be applied to text, titles, headers, captions, tables and so on.
HTML selector
The HTML elements name is used as a selector to redefine the associated HTML tag. For example, the selector for the <h1> tag is h1. The HTML selector is used in a CSS rule to redefine how the tag displays an HTML tag.
Class Selector
A class is a free agent that can be applied to any HTML tag. Because it can be applied to multiple HTML tags, a class is the most versatile type of selector .theClass { font: bold 12pt times; }
ID Selector
Much like classes, IDs can be applied to any HTML tag, but only once on a given page to a particular HTML tag, to create an object for use with a Javascript function #theobject { position: absolute; top: 10px; }
Coding CSS
The real advantage of using CSS instead of HTML is that by changing a few lines of code, you can change the appearance of every page of your Web site.
1. You must set up the rules in a text file. 2. Link or import the file into an HTML document using either the <link> tag or the @import rule