SlideShare a Scribd company logo
For more Https://www.ThesisScientist.com
UNIT 2
CLIENT SIDE PROGRAMMING
INTRODUCTION TO STYLE SHEET
“STYLE SHEET IS A COLLECTION OF FORMATTING STYLES, WHICH CAN BE
APPLIED TO A WEB PAGE.”
2.1 Benefits of the Style Sheets
Separation of style and content has many benefits:
1 Speed. Users experience of a site utilizing style sheets will generally be
quicker than sites that don‟t use the technology. „Overall‟ as the first
page will probably load more slowly – because the style sheet AND the
content will need to be transferred. Subsequent pages will load faster
because no style information will need to be downloaded – the CSS file
will already be in the browser's cache.
2 Maintainability. Holding all the presentation styles in one file significantly
reduces maintenance time, and reduces opportunity for human errors
by reducing the maintenance tasks.
3 Accessibility. Sites that use CSS with either XHTML or HTML are easier to
draw so that they appear extremely similar in different browsers
4 Customization. If a page's layout information is all stored externally, a user
can decide to disable the layout information entirely, leaving the site's
bare content still in a readable form. Site authors may also offer
multiple stylesheets, which can be used to completely change the
appearance of the site without altering any of its content.
5 Consistency. Because the semantic file contains only the meanings an
author intends to convey, the styling of the various elements of the
document's content is very consistent. For example, headings,
emphasized text, lists and mathematical expressions all receive
consistently applied style properties from the external stylesheet.
Authors need not concern themselves with the style properties at the
For more Https://www.ThesisScientist.com
time of composition. These presentational details can be deferred until
the moment of presentation.
6 Portability. The suspension of presentational details until the time of
presentation means that a document can be easily re-purposed for an
entirely different presentation medium with merely the application of a
new stylesheet already prepared for the new medium and consistent
with elemental or structural vocabulary of the semantic document.
2.2 Disadvantages of the Style Sheets
Currently specifications (for example, XHTML, XSL, CSS) and software tools
implementing these specification are only reaching the early stages of maturity. So
there are some practical issues facing authors who seek to embrace this method of
separating content and style.
1 Lack of semantic vocabulary. HTML offers a rich, but limited
vocabulary of semantic elements (for example paragraph, quote,
emphasis). The migration of HTML to the extensible XHTML may
eventually speed the proliferation of richer semantic vocabularies
to apply generalized styles to.
2 Complex Layouts. One of the practical problems is the lack of proper
support for style languages in major browsers. Typical web page layouts call for
some tabular presentation of the major parts of the page such as menu
navigation columns and header bars, navigation tabs, and so on. However,
deficient support for CSS and XSL in major browsers forces authors to code
these tables within their content rather than applying a tabular style to the
content from the accompanying stylesheet.
3 Narrow Adoption without the Parsing & Generation Tools. While the
style specifications are quite mature and still maturing, the software
tools have been slow to adapt. Most of the major web development tools
still hold a mixed presentation-content model. So authors and
designers looking for GUI based tools for their work find it difficult to
follow the semantic web method. In addition to GUI tools, shared
repositories for generalized stylesheets would probably aid adoption of
these methods.
The style sheet consists of the following components:
2.3 Style Rule
For more Https://www.ThesisScientist.com
“A STYLE RULE IS A SET OF HTML TAGS SPECIFYING THE FORMATTING
ELEMENTS.”
Style rules can be applied to selected contents of a web page.
A style rule can basically be split into two parts:
(a) Selector: A selector is a string that identifies what elements the
corresponding rule applies to and is the first part of the rule.
(b) Declaration: This part of the rule is enclosed within curly brackets. A
declaration has two sections separated by a colon. The section
before the colon tells the property, and the section after the colon is
the value of that property.
The syntax of a style rule is as follows:
Selector (property : value)
Where,
Selector = Any HTML tag
Property = Attribute like font color, font size, etc.
Value = Setting for the attribute
e.g. H1 { color : blue }
H1 is the selector, color : blue is the declaration color is the property and blue is the
value.
2.4 Selectors
The selectors in the style rule basically are categorized into:
2.4.4.1 Simple Selectors
These are the easiest to use. A SIMPLE SELECTOR DESCRIBES AN
ELEMENT IRRESPECTIVE OF ITS POSITION IN THE DOCUMENT
STRUCTURE. The H1 heading identifier is a typical example of simple
selector.
H1 { Color : blue }
2.44.2 HTML Selectors
For more Https://www.ThesisScientist.com
These selector use the names of HTML elements without brackets. So the
HTML <P> tag becomes P.
Example: In this example, while defining the style, the P element does not
have brackets.
<HTML>
<HEAD>
<STYLE>
P { font – style : italic ; font – weight : bold ; color : limegreen ; font –
size : 12 pt ; line – height : 16 pt }
</STYLE>
</HEAD>
<BODY>
<P> these selectors use the names of HTML elements. The only
difference is that the brackets are removed. </P>
</BODY></HTML>
2.5.4.3 Class Selectors
The class selector gives authors the ability to apply styles to specific parts
of a document and do not necessarily to the whole document
The syntax is:
<STYLE>
Class selector
. Class Name Class selector { Property : Value }
</STYLE>
<BODY>
<P Class = “Class Name”>
Class attribute
</BODY>
Class name can be any valid string of characters.
The class selector is preceded with a dot (.) called the flag character
Class selector can be applied to any of the HTML elements by using the
class attribute.
Example:
For more Https://www.ThesisScientist.com
<HTML>
<HEAD>
<STYLE>
. note { color : blue }
. syntax { color : red }
P. syntax { color : red }
P { font – size : large }
</STYLE>
</HEAD>
<BODY>
<P CLASS = “syntax”> The class selector is preceded with a dot (.) called
the flag character, followed by the „Class name‟.
<P CLASS = “note”> It is better to choose class name according to their
purpose rather than a name that describes their color or style.
<H1 CLASS = “note”> The class attribute is used even to the heading tag.
</H1>
</BODY>
</HTML>
2.6.4.4 ID Selectors
Like class selection, ID selector is also used to apply style to the selected
parts of text. In this style, each ID selector has a unique identifier. An ID
selector is preceded by a hash (#) mark and to apply ID selector the ID
attribute of an HTML element is used.
The syntax is:
<STYLE>
ID Selector name
# IDSelectorName {Property : Value}
</STYLE>
<BODY>
<P ID = “IDSelectorName”>
ID Attribute
For more Https://www.ThesisScientist.com
</BODY>
Example:
<HTML>
<HEAD>
<TITLE> ID SELECTOR </TITLE>
</HEAD>
<BODY>
<STYLE>
#Control { color : red }
</STYLE>
<H2 Id = “Control”> Fire is this color </H2>
<BR>
<H2> The browser controlled display of an H2 heading </H2>
<BR>
<P ID = “Control”> Applying an ID to a paragraph element. </P>
<BR>
<P> This is paragraph that has no style applied </P>
</BODY>
</HTML>
2.7.4.5 Contextual Selectors
Consider a situation where, some tags are under H1 that are italics. Now
to change any of their color to red following code could be used:
H1 { color : red }
I { color : red }
But in the above code, all type italicized tags turn to red. This is because
of the line 2 of the code.
To avoid such situation contextual selectors can be used. Contextual
selectors can be used to combine number of simple selector separated by a
space.
The above code now can be rewritten as:
H1 I { COLOR : RED }
The concept of contextual selectors support inheritance
Example:
For more Https://www.ThesisScientist.com
<HTML>
<HEAD>
<TITLE> contextual selectors </TITLE>
<STYLE>
body {
Color : Magenta;
Background : white;
Font – family : Arial;
}
ul {
color : aqua
}
</STYLE>
</HEAD>
</HTML>
2.5 Ways of Incorporating Styles in HTML document
There are four ways of incorporating style sheets in HTML document, which are:
 Including style information within HTML
 Embedding a style sheet
 Linking to an external style sheet
 Importing a style sheet
2.5.1 Including Style Information Inline – Inline Styles
Inline style declaration is the most basic style rule, which can be applied to individual
elements in the web page, Inline styles are implemented by using style attributes with
the HTML tags.
The syntax is :
<HTML TAG STYLE = “PROPERTY : VALUE”>
For more Https://www.ThesisScientist.com
e.g.
<P STYLE = { COLOR : OLIVE }>
Example: The style rule is applied to H1 tag by specifying it in the STYLE attribute.
<HTML>
<BODY>
<H1 STYLE = “Color : limegreen”> This is a style applied to an H1 element </H1>
<H1> This is the default display of an H1 element </H1>
</BODY>
</HTML>
The color property sets the color of the first H1 element to limegreen color and the
second one remains the default since no style attribute is applied.
2.5.2 Embedding Style Sheet
More than one style rule can be grouped by using <STYLE>……….</STYLE> tag
pair unlike of applying it individually in inline style. Each of these tags when used
in the BODY of the HTML code will apply the style rules.
The syntax is:
<HTML>
<HEAD>
<STYLE>
Style Rules
For more Https://www.ThesisScientist.com
</STYLE>
</HEAD>
<BODY>
…………
…………
…………
</BODY>
</HTML>
Example,
<HTML>
<HEAD>
<STYLE>
H1 { font – family : Arial }
H1 { Color : limegreen }
</STYLE>
</HEAD>
<BODY>
<H1> This is the H1 element </H1>
<H2> This is the H2 element </H2>
For more Https://www.ThesisScientist.com
………
</BODY>
</HTML>
2.5.3 Grouping Style Rules
Same style properties can be applied to more than one elements in a document by
grouping the style rules as shown below:
<HTML>
<HEAD>
<STYLE>
H1, H2 { Color : red ; font-family : Arial }
</STYLE>
</HEAD>
<BODY>
<H1>This is the H1 element </H1>
<H2>This is the H2 element </H2>
<H3>This is the H3 element with its default style as displayed in the browser </H3>
</BODY>
</HTML>
The above methods of modifying styles of elements are within the same page. To apply
similar settings for all the pages in the website, all the style rules should be put into a
For more Https://www.ThesisScientist.com
style sheet File and then imported or linked with the HTML document. This method of
linking or importing is called CASCADING STYLE SHEETS (CSS).
2.5.4 Linking to an External Style Sheet
For constructing a CSS, first style rules must be written in a document and saves in a
separate file with extension of CSS. The syntax for linking to an external style sheet is:
<HTML>
<HEAD>
<LINK REL = “STYLESHEET” HREF = “Dictionary path where the style sheet is saved”>
</HEAD>
<BODY>
………
………
</BODY>
</HTML>
Where REL = STYLESHEET – Relation to the external document in a style sheet.
For example, consider a style sheet definition which specifies two styles:
 a global style applies to all <H2> element (green, arial font family, normal size)
For more Https://www.ThesisScientist.com
 a generic style class named warning (red, bold, italic) which will apply to any
element which uses that class.
Style 1. CSS has the following code:
<STYLE>
H2 { COLOR : limegreen;
font – family : “Arial”;
font – size : normal
}
Warning { color : red;
font – weight : bold;
font –style : italic
}
</STYLE>
HTML file:
<HTML>
<HEAD>
<TITLE> Changing the rules </TITLE>
</HEAD>
<H2> Changing the rules is fun </H2>
<BR>
For more Https://www.ThesisScientist.com
<P class = “warning”> Changing the rules may not be such fun
<H2> The H2 element again </H2>
</HTML>
TYPE = “text / css”
2.5.5 Importing a Style Sheet
Importing a style sheet, automatically pulls, the style rules into the document for
use. Once imported, changes made to the style sheet will not be reflected in the web
page into which it has been imported. This problem can be avoided by linking the
style sheet to the main document rather than importing it.
The syntax is:
<HTML>
<HEAD>
<STYLE TYPE = “TEXT / CSS”>
@ IMPORT URL (The Path) ;
</STYLE>
</HEAD>
<BODY>
………
………
</BODY></HTML>
2.5.6 Style Sheet Properties
For more Https://www.ThesisScientist.com
Font Properties.
(a) font-family – Denotes font
(b) font-size – Denotes the size of the text.
(c) font-style – Denotes the style of the text for example normal, bold, italic
etc.
(d) font-weight – Denotes the weight or darkness of the font. This value
ranges from 100 to 900 increments of 100.
Text Properties.
(a) Letter-spacing – Denotes the space between letters (in inches(in),
centimeters (cm), millimeter (mm), or points (pt), etc.).
(b) Word-spacing – Denotes the space between words (in inches(in),
centimeters (cm), millimeter (mm), or points (pt), etc.).
(c) Vertical-Align – Denotes the vertical positioning of the text and images,
with respect to the baseline. The possible values include baseline, sub, top,
text-top middle percentage values, etc.
(d) Text-Align – Specifies the alignment of the text. Possible values: center,
justify, etc.
(e) Text-indent – Denotes margins. This property sets the indentation for text
in the first line of block level element.
(f) Text-decorate – Denotes the text‟s decoration. The standard values for
this property include blink, line – through over line underline etc.
For more Https://www.ThesisScientist.com
Color and Background Properties.
(a) Color – Denotes the color property, used to set text color.
(b) Background-color – This property sets an element‟s background color.
(c) Background-image – Associates a background image with an element.
(d) Background-position – Specifies how a background image is positioned.
Box Properties.
Block style elements such as the <P> element can be considered as
rectangular boxes on the screen. These properties include:
(a) Margin Properties – The margin values should be in length like 15 pt. etc.
The individual margins for a block element can be set using margin-top,
margin-rigid, margin-bottom, or margin-left.
(b) Border Properties:
 Border-style – Used to set the appearance of the borders. The
values can include solid, double, groove, ridge, etc.
 Border-width – The width of the border is specified here. The
individual border width can be set using border-top-width
border-right-width, border-bottom-width, border-left-width etc.
 Border-color – Border may be assigned a color.

More Related Content

PPTX
Html5
PDF
Introduction to HTML
PPT
Xhtml
PDF
Introduction to CSS
PPTX
HTML 5 Topic 2
PPTX
html tutorial
PPTX
HTML5 Topic 1
PDF
Introduction to CSS3
Html5
Introduction to HTML
Xhtml
Introduction to CSS
HTML 5 Topic 2
html tutorial
HTML5 Topic 1
Introduction to CSS3

What's hot (20)

PPTX
Xhtml
PPTX
HTML CSS | Computer Science
PDF
HTML - part 1
PDF
Introduction to Javascript
DOCX
Practical file on web technology(html)
PPTX
Empowerment Technologies Lecture 10 (Philippines SHS)
PPT
Diva
PPTX
4. html css-java script-basics
PPTX
POLITEKNIK MALAYSIA
PPTX
Html5 attributes
PPTX
MTA html5 organization, input, and validation
PDF
HTML Email
PDF
HTML practical file
PPTX
Introduction to Html
PPTX
HTML - R.D.Sivakumar
PDF
Html & Html5 from scratch
DOCX
Html viva questions
PDF
Week 2-intro-html
PPTX
DOCX
Xhtml
HTML CSS | Computer Science
HTML - part 1
Introduction to Javascript
Practical file on web technology(html)
Empowerment Technologies Lecture 10 (Philippines SHS)
Diva
4. html css-java script-basics
POLITEKNIK MALAYSIA
Html5 attributes
MTA html5 organization, input, and validation
HTML Email
HTML practical file
Introduction to Html
HTML - R.D.Sivakumar
Html & Html5 from scratch
Html viva questions
Week 2-intro-html
Ad

Similar to CLIENT SIDE PROGRAMMING (20)

PPTX
This is css which compiled by alex that is impo
PPTX
Web technology Unit-II Part-C
PPT
ITEC229_Chapter8_new.ppt computer architecture
PDF
Introduction to css
DOC
Css introduction
PDF
Cascading Style Sheets
PPTX
website design mark-up with HTML 5 .pptx
PPT
Shyam sunder Rajasthan Computer
PPT
Using Cascading Style Sheets2
PPTX
lecture CSS 1-2_2022_2023.pptx
PPTX
Lecture-6.pptx
PDF
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
PPTX
Lecture 9 CSS part 1.pptxType Classification
PPTX
Lecture 3CSS part 1.pptx
PPT
CSS Training in Bangalore
PPT
SDP_-_Module_4.ppt
PPT
New Css style
PPT
Html5 css3
This is css which compiled by alex that is impo
Web technology Unit-II Part-C
ITEC229_Chapter8_new.ppt computer architecture
Introduction to css
Css introduction
Cascading Style Sheets
website design mark-up with HTML 5 .pptx
Shyam sunder Rajasthan Computer
Using Cascading Style Sheets2
lecture CSS 1-2_2022_2023.pptx
Lecture-6.pptx
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Lecture 9 CSS part 1.pptxType Classification
Lecture 3CSS part 1.pptx
CSS Training in Bangalore
SDP_-_Module_4.ppt
New Css style
Html5 css3
Ad

More from Prof Ansari (20)

PDF
Sci Hub New Domain
PDF
Sci Hub cc Not Working
PDF
basics of computer network
PDF
JAVA INTRODUCTION
PDF
Project Evaluation and Estimation in Software Development
PDF
Stepwise Project planning in software development
PDF
Database and Math Relations
PDF
Normalisation in Database management System (DBMS)
PDF
Entity-Relationship Data Model in DBMS
PDF
A Detail Database Architecture
PDF
INTRODUCTION TO Database Management System (DBMS)
PDF
Master thesis on Vehicular Ad hoc Networks (VANET)
PDF
Master Thesis on Vehicular Ad-hoc Network (VANET)
PDF
INTERFACING WITH INTEL 8251A (USART)
PDF
HOST AND NETWORK SECURITY by ThesisScientist.com
PDF
SYSTEM NETWORK ADMINISTRATIONS GOALS and TIPS
PDF
INTRODUCTION TO VISUAL BASICS
PDF
introduction to Blogging ppt
PDF
INTRODUCTION TO SOFTWARE ENGINEERING
PDF
Introduction to E-commerce
Sci Hub New Domain
Sci Hub cc Not Working
basics of computer network
JAVA INTRODUCTION
Project Evaluation and Estimation in Software Development
Stepwise Project planning in software development
Database and Math Relations
Normalisation in Database management System (DBMS)
Entity-Relationship Data Model in DBMS
A Detail Database Architecture
INTRODUCTION TO Database Management System (DBMS)
Master thesis on Vehicular Ad hoc Networks (VANET)
Master Thesis on Vehicular Ad-hoc Network (VANET)
INTERFACING WITH INTEL 8251A (USART)
HOST AND NETWORK SECURITY by ThesisScientist.com
SYSTEM NETWORK ADMINISTRATIONS GOALS and TIPS
INTRODUCTION TO VISUAL BASICS
introduction to Blogging ppt
INTRODUCTION TO SOFTWARE ENGINEERING
Introduction to E-commerce

Recently uploaded (20)

PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
composite construction of structures.pdf
PPTX
additive manufacturing of ss316l using mig welding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CH1 Production IntroductoryConcepts.pptx
DOCX
573137875-Attendance-Management-System-original
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
UNIT 4 Total Quality Management .pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
PPT on Performance Review to get promotions
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Geodesy 1.pptx...............................................
R24 SURVEYING LAB MANUAL for civil enggi
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Internet of Things (IOT) - A guide to understanding
composite construction of structures.pdf
additive manufacturing of ss316l using mig welding
Model Code of Practice - Construction Work - 21102022 .pdf
Foundation to blockchain - A guide to Blockchain Tech
CH1 Production IntroductoryConcepts.pptx
573137875-Attendance-Management-System-original
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
CYBER-CRIMES AND SECURITY A guide to understanding
UNIT 4 Total Quality Management .pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Embodied AI: Ushering in the Next Era of Intelligent Systems
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPT on Performance Review to get promotions
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Geodesy 1.pptx...............................................

CLIENT SIDE PROGRAMMING

  • 1. For more Https://www.ThesisScientist.com UNIT 2 CLIENT SIDE PROGRAMMING INTRODUCTION TO STYLE SHEET “STYLE SHEET IS A COLLECTION OF FORMATTING STYLES, WHICH CAN BE APPLIED TO A WEB PAGE.” 2.1 Benefits of the Style Sheets Separation of style and content has many benefits: 1 Speed. Users experience of a site utilizing style sheets will generally be quicker than sites that don‟t use the technology. „Overall‟ as the first page will probably load more slowly – because the style sheet AND the content will need to be transferred. Subsequent pages will load faster because no style information will need to be downloaded – the CSS file will already be in the browser's cache. 2 Maintainability. Holding all the presentation styles in one file significantly reduces maintenance time, and reduces opportunity for human errors by reducing the maintenance tasks. 3 Accessibility. Sites that use CSS with either XHTML or HTML are easier to draw so that they appear extremely similar in different browsers 4 Customization. If a page's layout information is all stored externally, a user can decide to disable the layout information entirely, leaving the site's bare content still in a readable form. Site authors may also offer multiple stylesheets, which can be used to completely change the appearance of the site without altering any of its content. 5 Consistency. Because the semantic file contains only the meanings an author intends to convey, the styling of the various elements of the document's content is very consistent. For example, headings, emphasized text, lists and mathematical expressions all receive consistently applied style properties from the external stylesheet. Authors need not concern themselves with the style properties at the
  • 2. For more Https://www.ThesisScientist.com time of composition. These presentational details can be deferred until the moment of presentation. 6 Portability. The suspension of presentational details until the time of presentation means that a document can be easily re-purposed for an entirely different presentation medium with merely the application of a new stylesheet already prepared for the new medium and consistent with elemental or structural vocabulary of the semantic document. 2.2 Disadvantages of the Style Sheets Currently specifications (for example, XHTML, XSL, CSS) and software tools implementing these specification are only reaching the early stages of maturity. So there are some practical issues facing authors who seek to embrace this method of separating content and style. 1 Lack of semantic vocabulary. HTML offers a rich, but limited vocabulary of semantic elements (for example paragraph, quote, emphasis). The migration of HTML to the extensible XHTML may eventually speed the proliferation of richer semantic vocabularies to apply generalized styles to. 2 Complex Layouts. One of the practical problems is the lack of proper support for style languages in major browsers. Typical web page layouts call for some tabular presentation of the major parts of the page such as menu navigation columns and header bars, navigation tabs, and so on. However, deficient support for CSS and XSL in major browsers forces authors to code these tables within their content rather than applying a tabular style to the content from the accompanying stylesheet. 3 Narrow Adoption without the Parsing & Generation Tools. While the style specifications are quite mature and still maturing, the software tools have been slow to adapt. Most of the major web development tools still hold a mixed presentation-content model. So authors and designers looking for GUI based tools for their work find it difficult to follow the semantic web method. In addition to GUI tools, shared repositories for generalized stylesheets would probably aid adoption of these methods. The style sheet consists of the following components: 2.3 Style Rule
  • 3. For more Https://www.ThesisScientist.com “A STYLE RULE IS A SET OF HTML TAGS SPECIFYING THE FORMATTING ELEMENTS.” Style rules can be applied to selected contents of a web page. A style rule can basically be split into two parts: (a) Selector: A selector is a string that identifies what elements the corresponding rule applies to and is the first part of the rule. (b) Declaration: This part of the rule is enclosed within curly brackets. A declaration has two sections separated by a colon. The section before the colon tells the property, and the section after the colon is the value of that property. The syntax of a style rule is as follows: Selector (property : value) Where, Selector = Any HTML tag Property = Attribute like font color, font size, etc. Value = Setting for the attribute e.g. H1 { color : blue } H1 is the selector, color : blue is the declaration color is the property and blue is the value. 2.4 Selectors The selectors in the style rule basically are categorized into: 2.4.4.1 Simple Selectors These are the easiest to use. A SIMPLE SELECTOR DESCRIBES AN ELEMENT IRRESPECTIVE OF ITS POSITION IN THE DOCUMENT STRUCTURE. The H1 heading identifier is a typical example of simple selector. H1 { Color : blue } 2.44.2 HTML Selectors
  • 4. For more Https://www.ThesisScientist.com These selector use the names of HTML elements without brackets. So the HTML <P> tag becomes P. Example: In this example, while defining the style, the P element does not have brackets. <HTML> <HEAD> <STYLE> P { font – style : italic ; font – weight : bold ; color : limegreen ; font – size : 12 pt ; line – height : 16 pt } </STYLE> </HEAD> <BODY> <P> these selectors use the names of HTML elements. The only difference is that the brackets are removed. </P> </BODY></HTML> 2.5.4.3 Class Selectors The class selector gives authors the ability to apply styles to specific parts of a document and do not necessarily to the whole document The syntax is: <STYLE> Class selector . Class Name Class selector { Property : Value } </STYLE> <BODY> <P Class = “Class Name”> Class attribute </BODY> Class name can be any valid string of characters. The class selector is preceded with a dot (.) called the flag character Class selector can be applied to any of the HTML elements by using the class attribute. Example:
  • 5. For more Https://www.ThesisScientist.com <HTML> <HEAD> <STYLE> . note { color : blue } . syntax { color : red } P. syntax { color : red } P { font – size : large } </STYLE> </HEAD> <BODY> <P CLASS = “syntax”> The class selector is preceded with a dot (.) called the flag character, followed by the „Class name‟. <P CLASS = “note”> It is better to choose class name according to their purpose rather than a name that describes their color or style. <H1 CLASS = “note”> The class attribute is used even to the heading tag. </H1> </BODY> </HTML> 2.6.4.4 ID Selectors Like class selection, ID selector is also used to apply style to the selected parts of text. In this style, each ID selector has a unique identifier. An ID selector is preceded by a hash (#) mark and to apply ID selector the ID attribute of an HTML element is used. The syntax is: <STYLE> ID Selector name # IDSelectorName {Property : Value} </STYLE> <BODY> <P ID = “IDSelectorName”> ID Attribute
  • 6. For more Https://www.ThesisScientist.com </BODY> Example: <HTML> <HEAD> <TITLE> ID SELECTOR </TITLE> </HEAD> <BODY> <STYLE> #Control { color : red } </STYLE> <H2 Id = “Control”> Fire is this color </H2> <BR> <H2> The browser controlled display of an H2 heading </H2> <BR> <P ID = “Control”> Applying an ID to a paragraph element. </P> <BR> <P> This is paragraph that has no style applied </P> </BODY> </HTML> 2.7.4.5 Contextual Selectors Consider a situation where, some tags are under H1 that are italics. Now to change any of their color to red following code could be used: H1 { color : red } I { color : red } But in the above code, all type italicized tags turn to red. This is because of the line 2 of the code. To avoid such situation contextual selectors can be used. Contextual selectors can be used to combine number of simple selector separated by a space. The above code now can be rewritten as: H1 I { COLOR : RED } The concept of contextual selectors support inheritance Example:
  • 7. For more Https://www.ThesisScientist.com <HTML> <HEAD> <TITLE> contextual selectors </TITLE> <STYLE> body { Color : Magenta; Background : white; Font – family : Arial; } ul { color : aqua } </STYLE> </HEAD> </HTML> 2.5 Ways of Incorporating Styles in HTML document There are four ways of incorporating style sheets in HTML document, which are:  Including style information within HTML  Embedding a style sheet  Linking to an external style sheet  Importing a style sheet 2.5.1 Including Style Information Inline – Inline Styles Inline style declaration is the most basic style rule, which can be applied to individual elements in the web page, Inline styles are implemented by using style attributes with the HTML tags. The syntax is : <HTML TAG STYLE = “PROPERTY : VALUE”>
  • 8. For more Https://www.ThesisScientist.com e.g. <P STYLE = { COLOR : OLIVE }> Example: The style rule is applied to H1 tag by specifying it in the STYLE attribute. <HTML> <BODY> <H1 STYLE = “Color : limegreen”> This is a style applied to an H1 element </H1> <H1> This is the default display of an H1 element </H1> </BODY> </HTML> The color property sets the color of the first H1 element to limegreen color and the second one remains the default since no style attribute is applied. 2.5.2 Embedding Style Sheet More than one style rule can be grouped by using <STYLE>……….</STYLE> tag pair unlike of applying it individually in inline style. Each of these tags when used in the BODY of the HTML code will apply the style rules. The syntax is: <HTML> <HEAD> <STYLE> Style Rules
  • 9. For more Https://www.ThesisScientist.com </STYLE> </HEAD> <BODY> ………… ………… ………… </BODY> </HTML> Example, <HTML> <HEAD> <STYLE> H1 { font – family : Arial } H1 { Color : limegreen } </STYLE> </HEAD> <BODY> <H1> This is the H1 element </H1> <H2> This is the H2 element </H2>
  • 10. For more Https://www.ThesisScientist.com ……… </BODY> </HTML> 2.5.3 Grouping Style Rules Same style properties can be applied to more than one elements in a document by grouping the style rules as shown below: <HTML> <HEAD> <STYLE> H1, H2 { Color : red ; font-family : Arial } </STYLE> </HEAD> <BODY> <H1>This is the H1 element </H1> <H2>This is the H2 element </H2> <H3>This is the H3 element with its default style as displayed in the browser </H3> </BODY> </HTML> The above methods of modifying styles of elements are within the same page. To apply similar settings for all the pages in the website, all the style rules should be put into a
  • 11. For more Https://www.ThesisScientist.com style sheet File and then imported or linked with the HTML document. This method of linking or importing is called CASCADING STYLE SHEETS (CSS). 2.5.4 Linking to an External Style Sheet For constructing a CSS, first style rules must be written in a document and saves in a separate file with extension of CSS. The syntax for linking to an external style sheet is: <HTML> <HEAD> <LINK REL = “STYLESHEET” HREF = “Dictionary path where the style sheet is saved”> </HEAD> <BODY> ……… ……… </BODY> </HTML> Where REL = STYLESHEET – Relation to the external document in a style sheet. For example, consider a style sheet definition which specifies two styles:  a global style applies to all <H2> element (green, arial font family, normal size)
  • 12. For more Https://www.ThesisScientist.com  a generic style class named warning (red, bold, italic) which will apply to any element which uses that class. Style 1. CSS has the following code: <STYLE> H2 { COLOR : limegreen; font – family : “Arial”; font – size : normal } Warning { color : red; font – weight : bold; font –style : italic } </STYLE> HTML file: <HTML> <HEAD> <TITLE> Changing the rules </TITLE> </HEAD> <H2> Changing the rules is fun </H2> <BR>
  • 13. For more Https://www.ThesisScientist.com <P class = “warning”> Changing the rules may not be such fun <H2> The H2 element again </H2> </HTML> TYPE = “text / css” 2.5.5 Importing a Style Sheet Importing a style sheet, automatically pulls, the style rules into the document for use. Once imported, changes made to the style sheet will not be reflected in the web page into which it has been imported. This problem can be avoided by linking the style sheet to the main document rather than importing it. The syntax is: <HTML> <HEAD> <STYLE TYPE = “TEXT / CSS”> @ IMPORT URL (The Path) ; </STYLE> </HEAD> <BODY> ……… ……… </BODY></HTML> 2.5.6 Style Sheet Properties
  • 14. For more Https://www.ThesisScientist.com Font Properties. (a) font-family – Denotes font (b) font-size – Denotes the size of the text. (c) font-style – Denotes the style of the text for example normal, bold, italic etc. (d) font-weight – Denotes the weight or darkness of the font. This value ranges from 100 to 900 increments of 100. Text Properties. (a) Letter-spacing – Denotes the space between letters (in inches(in), centimeters (cm), millimeter (mm), or points (pt), etc.). (b) Word-spacing – Denotes the space between words (in inches(in), centimeters (cm), millimeter (mm), or points (pt), etc.). (c) Vertical-Align – Denotes the vertical positioning of the text and images, with respect to the baseline. The possible values include baseline, sub, top, text-top middle percentage values, etc. (d) Text-Align – Specifies the alignment of the text. Possible values: center, justify, etc. (e) Text-indent – Denotes margins. This property sets the indentation for text in the first line of block level element. (f) Text-decorate – Denotes the text‟s decoration. The standard values for this property include blink, line – through over line underline etc.
  • 15. For more Https://www.ThesisScientist.com Color and Background Properties. (a) Color – Denotes the color property, used to set text color. (b) Background-color – This property sets an element‟s background color. (c) Background-image – Associates a background image with an element. (d) Background-position – Specifies how a background image is positioned. Box Properties. Block style elements such as the <P> element can be considered as rectangular boxes on the screen. These properties include: (a) Margin Properties – The margin values should be in length like 15 pt. etc. The individual margins for a block element can be set using margin-top, margin-rigid, margin-bottom, or margin-left. (b) Border Properties:  Border-style – Used to set the appearance of the borders. The values can include solid, double, groove, ridge, etc.  Border-width – The width of the border is specified here. The individual border width can be set using border-top-width border-right-width, border-bottom-width, border-left-width etc.  Border-color – Border may be assigned a color.