What you absolutely must know about CSS!

Style sheet is an innovative step forward for the development of the web. Presently, an increasing number of browsers implement style sheets, allowing authors to take advantage of unique presentational features that preserve platform independence. With the gradual development of CSS, the advantages of style sheets have become evident, while the disadvantage of continually creating more HTML tags for presentation effects has multiplied.

Let’s understand CSS from the proper angle.

Style sheets in hindsight

Style sheets have existed in one form or another since the early 1990s, when HTML was first introduced.

In order to meet the needs of web developers, HTML expanded to include a wider range of stylistic capabilities as it evolved. With these capabilities, style sheets became less important, and until CSS was developed, an external language for defining style attributes was not widely accepted.

There are teething problems with CSS implementation.

Numerous CSS implementations are riddled with inconsistencies, bugs, and other peculiarities. Commonly, authors have had to resort to hacks and workarounds to achieve consistent results across web browsers and platforms.

The Internet Explorer box model bug is one of the most well-known CSS bugs; box widths are interpreted incorrectly in multiple browser versions, resulting in blocks that appear as expected in most browsers but are too narrow when viewed in Internet Explorer. The bug can be avoided, but only at the expense of functionality.

This is just one of hundreds of CSS bugs documented in different versions of Internet Explorer, Netscape, Mozilla, and Opera, many of which reduce the legibility of documents. The proliferation of such bugs in CSS implementations has made it difficult for designers to achieve platform-wide consistency in appearance.

Currently, there is a fierce competition between Mozilla’s Gecko layout engine, Opera’s Presto layout engine, and the KHTML engine used in Apple’s Safari and the Linux Konqueror browser; each of these engines is the leader in a different aspect of CSS. Internet Explorer remains the worst browser for rendering CSS according to 2005 World Wide Web Consortium standards.

Several breakthroughs…

These issues prompted the W3C to revise CSS2 into CSS2.1, which can be viewed as a snapshot of current CSS support. No-browser-implemented CSS2 properties were eliminated, and in a few instances, defined behaviors were modified to align the standard with the majority of existing implementations.

What makes style sheets sufficiently significant?

It represents a significant step forward for the Web. With the separation of content and presentation between HTML and style sheets, the Web no longer needs to stray from the platform-independent ideal that initially propelled the medium’s popularity. Authors can now affect the presentation of documents without rendering pages unreadable.

A style sheet contains style rules that instruct a browser on how to render a document. There are multiple ways to link these style rules to your HTML documents, but the simplest way to begin is by utilizing the STYLE element. This element is located in the HEAD of the document and contains the page’s style rules.

CSS Functionality and Application

The design of CSS permits the separation of presentation and structure. Prior to CSS, nearly all presentational attributes of an HTML document were contained in the HTML code; all font colors, background styles, element alignments, borders, and sizes had to be described explicitly, frequently multiple times, within the HTML code.

CSS enables authors to move a significant portion of this information to a stylesheet, resulting in significantly less complex HTML code. The HTML documents are significantly reduced in size, and web browsers will typically cache CSS stylesheets. This reduces network traffic and significantly accelerates page downloads.

For instance, the HTML element h2 indicates that the text it contains is a level two heading. It is less significant than h1 headings but more significant than h3 headings. This h2 element property is structural.

Typically, headings are rendered in decreasing order of size, with h1 being the largest. This is because larger headings are typically interpreted as having greater significance than smaller ones. Typically, headings are rendered in a bold font to give them additional emphasis. The h2 element can be rendered with bold text and a font size that is larger than h3 but smaller than h1. This h2 element property is presentational.

Prior to CSS, authors of documents who wished to assign a specific color, font, size, or other attribute to all h2 headings had to use the HTML font element for each instance of that heading type.

In addition, CSS can be used in conjunction with XML to render such structured documents with complete control over layout, typography, color, etc. in any suitable user agent or web browser.

CSS also has a number of inconsistencies.

CSS may occasionally be abused, particularly by web document authors. Some developers who are used to designing documents solely in HTML may overlook or disregard the enabling properties of CSS. For example, a document author who is familiar with HTML markup that combines presentation and structure may choose to embed CSS styles in every document. This may be an improvement over the use of deprecated HTML presentational markup, but it suffers from many of the same issues as mixed-markup HTML, including a similar amount of document maintenance.

CSS is contrasted with programming languages.

CSS shares a number of pitfalls with programming languages. Particularly, CSS authors may struggle with selecting appropriate names for CSS classes and identifiers. In an effort to choose descriptive names for CSS classes, authors may associate the class name with desired presentational attributes; for instance, a CSS class to be applied to highlighted text could be named “bigred,” implying that it is rendered in a large red font.

While such a naming choice may be intuitive for the author of the document, it can cause issues if the author later decides that the highlighted text should be green; the author is left with a CSS class named “bigred” that describes something that is green. In this instance, a more suitable class name could have been “emphasized” to better describe the class’s purpose or intent, rather than the appearance of its constituent elements.

In a programming language, this would be analogous to using the variable name “five” for a variable whose value is 5; if the variable’s value changes to 7, the name is no longer appropriate.

CSS in concise form

CSS is used by both authors and viewers of web pages to define colors, fonts, layout, and other presentation-related aspects of documents. It is intended to separate document structure (written in HTML or a similar markup language) from document presentation (written in CSS).

This separation offers several advantages, including improved content accessibility, greater flexibility and control in the specification of presentational characteristics, and simplified structural content. CSS can also control the document’s style independently for alternative rendering methods, such as on-screen in print, by voice (when read out by a speech-based browser or screen reader), and on braille-based, tactile devices.

CSS enables total and complete control over the style of an HTML document. The only way to illustrate this in a way that excites people is to show what it can become when the reins are placed in the hands of those who can create beauty from structure.

Leave a Comment

Your email address will not be published.