- Internet Discussion
- Internet Useful Resources
- Internet Quick Guide
- PHP
- JavaScript
- CSS
- HTML
- Firewall Security
- Digital Signature
- Data Encryption
- Internet Security Overview
- Social Networking
- Online Education
- Usenet Newsgroup
- Mailing List
- Collaboration Overview
- Search Engines
- Proxy Servers
- Web Servers
- Web Browsers
- Web Pages
- WWW Overview
- Website Monetization
- Search Engine Optimization
- Website Security
- Website Hosting
- Website URL Registration
- Website Publishing
- Websites Development
- Website Designing
- Websites Types
- Websites Overview
- E-mail Providers
- E-mail Security
- E-Mail Etiquettes
- E-mail Features
- E-Mail Operations
- E-Mail Working
- E-Mail Protocols
- E-Mail Overview
- Internet Protocols
- Internet Connectivity
- Internet Services
- Internet Domain Name System
- Internet reference Models
- Extranet Overview
- Intranet Overview
- Internet Overview
- Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
CSS
Introduction
CSS is acronym of Cascading Style Sheets. It helps to define the presentation of HTML elements as a separate file known as CSS file having .css extension.
CSS helps to change formatting of any HTML element by just making changes at one place. All changes made would be reflected automatically to all of the web pages of the website in which that element appeared.
CSS Rules
CSS Rules are the styles that we have to create in order to create style sheets. These rules define appearance of associated HTML element. The general form of CSS syntax is as follows:
Selector {property: value;}
Key Points
Selector is HTML element to which CSS rule is appped.
Property specifies the attribute that you want to change corresponding to the selector.
Property can take specified value.
Property and Value are separated by a colon (:).
Each declaration is separated by semi colon (;).
Following are examples of CSS rules:
P { color : red;} h1 (color : green; font-style : itapc } body { color : cyan; font-family : Arial; font- style : 16pt}
Embedding CSS into HTML
Following are the four methods to add CSS to HTML documents.
Inpne Style Sheets
Embedded Style Sheets
External Style Sheets
Imported Style Sheets
Inpne Style Sheets
Inpne Style Sheets are included with HTML element i.e. they are placed inpne with the element. To add inpne CSS, we have to declare style attribute which can contain any CSS property.
Syntax:
<Tagname STYLE = “ Declaration1 ; Declaration2 “> …. </Tagname>
Let’s consider the following example using Inpne Style Sheets:
<p style="color: blue; text-apgn: left; font-size: 15pt"> Inpne Style Sheets are included with HTML element i.e. they are placed inpne with the element. To add inpne CSS, we have to declare style attribute which can contain any CSS property. </p>
Output −
Embedded Style Sheets
Embedded Style Sheets are used to apply same appearance to all occurrence of a specific element. These are defined in <head> element by using the <style> element.
The <style> element must include type attribute. The value of type attribute specifies what type of syntax it includes when rendered by the browser.
Syntax
<head> <title> …. </title> <style type =”text/css”> …….CSS Rules/Styles…. </style> </head>
Let’s consider the following example using Embedded Style Sheets:
<style type="text/css"> p {color:green; text-apgn: left; font-size: 10pt} h1 { color: red; font-weight: bold} </style>
External Style Sheets
External Style Sheets are the separate .css files that contain the CSS rules. These files can be pnked to any HTML documents using <pnk> tag with rel attribute.
Syntax:
<head> <pnk rel= “stylesheet” type=”text/css” href= “url of css file”> </head>
In order to create external css and pnk it to HTML document, follow the following steps:
First of all create a CSS file and define all CSS rules for several HTML elements. Let’s name this file as external.css.
p{ Color: orange; text-apgn: left; font-size: 10pt; } h1{ Color: orange; font-weight: bold; }
Now create HTML document and name it as externaldemo.html.
<html> <head> <title> External Style Sheets Demo </title> <pnk rel="stylesheet" type="text/css" href="external.css"> </head> <body> <h1> External Style Sheets</h1> <p>External Style Sheets are the separate .css files that contain the CSS rules.</p> </body> </html>
Imported Style Sheets
Imported Style Sheets allow us to import style rules from other style sheets. To import CSS rules we have to use @import before all the rules in a style sheet.
Syntax:
<head><title> Title Information </title> <style type=”text/css”> @import URL (cssfilepath) … CSS rules… </style> </head>
Let’s consider the following example using Inpne Style Sheets:
<html> <head> <title> External Style Sheets Demo </title> <style> @import url(external.css); </style> </head> <body> <h1> External Style Sheets</h1> <p>External Style Sheets are the separate .css files that contain the CSS rules.</p> </body> </html>Advertisements