Computer highlight CH-3
Computer highlight CH-3
to appear in bold, then we have to insert the bold tag every time the
tag appears in the source code. If the website is large, repeating the tag every time becomes tedious and time-consuming. But using CSS, we can set all element types to appear in a style as per our choice. So even if we have more number of
tags in the website, using CSS we can set the style for all the
tags at once.
Thus we can say that, HTML is used to describe the information content of the document and
not the style, while CSS describes the style of the elements in the document and not its contents.
Using CSS, we can control the font types, font and element colors, pad spaces, margins, and element
positions in our website.
Syntax of CSS
‘The syntax of CSS consists of special symbols known as rules. A CSS rule has two main parts:
a selector, and one or more declarations. The selector is the HTML element on which you want
to apply the style. Declaration consists of a property associated with the HTML element used in
selector and its corresponding value, The general syntax of CSS is defined as:
selector {property : value}
Figure 2.1 gives an example of one such syntax :
H1{ color: green }
Selector Property Value
Figure 2.1 : Syntax of CSS
We can easily add CSS using KompoZer. Let us learn how to add CSS to a web page in KompoZer.
To make sure that KompoZer uses CSS by default, click Edit > Preferences, This will open
Options dialog box as shown in figure 2.2. Select the General category on the left side of the window.
Select the checkbox "Use CSS styles instead of HTML elements and attributes" if it is not selected.
KompoZer will now use the CSS styling instead of HTML to format the text.
Highlighted by Pragati Computers, M. 9904167671.
Highlighted by Pragati Computers, M. 9904167671.
Cascading Style Sheets and Java script 28Highlighted by Pragati Computers, M. 9904167671.
Recent Pages Menu
Maximum pumberor pageslistee: [10
When saving or Publishing Pages
New page Settings | @ Retain original source formatting
i Reformat HTML source
advanced Saveimagesand other assocatediies when saving pages
S Always show Publish dlaloawhen publishing pages
Apolcatons — -Tabletdlting
& Naintaintablelaysutwheninserting or deleting cells
+ Caiending syle sheets (55) Eating
© Use C55 styesinstead of ML elements and atrbutes
site manager ——=——————___———
Always open document ina newtab
1 Use system icons
Figure 2.2 : Options dialog box
‘Assume that we Want to design a website and the heading on all the web pages should follow
a particular style. For example, all the Headings! (h1) inserted in the web pages should follow the
style as given :
> Font : Times New Roman
> Case : Uppercase
= Alignment : Centre aligned
> Background color : Light Blue
> Border : Dotted Border
Follow the steps given to create the CSS for the above heading.
© Open a new file. Give the Title name and save the file.
In the composition toolbar, select the Cascade button © sot: te Hie isnot saved,
the Page title dialog box will be opened. After giving the page title, save the file). This will open
the dialog box as shown in figure 2.3. Using this dialog box we will define the styles for each
element, Click on the first radio button "style applied to all the elements of type”.
26 ‘Computer Studies : 12
Highlighted by Pragati Computers, M. 9904167671.Highlighted by Pragati Computers, M. 9904167671.
Sheetsond rules New Style rule
[> internal stylesheet @ style applied to all elements oF type
eg.hz
style applied to all elements ofc
eg..myelass
Create anew:
style appliedto an element with specified 0 attribute
eg.#header
custom stylerule
eg. divsheader a:hover
int
Create siyteruie
Figure 2.3: CSS Stylesheets dialog box
© From the drop down menu choose an element to create the style rule, As we want to create
style for Heading], we have selected hl (Heading 1) from the drop down menu as shown
in figure 2.3.
© Click the Create Style rule button. You will see that the CSS Stylesheets dialog box remains
open but the options will change.
© Figure 2.4 shows the hl element just below the heading “internal stylesheet” on the left pane
of the window. For each element we add, a style rule will appear in this list below the heading
“internal stylesheet". On the right side of the window, you will see various tabs like General,
Text, Background, Borders, Box, Lists and Aural. Each of these tabs can be used to give a
specific style to the element. But all the tabs may not be applicable to the selector for which
the style rule is created. Now, let us create the style rule for hl. selector.
re ee ee er oe
ts andes Style rule
= wiicernalstyester Selector, bt
ha
cancel
Figure 2.4: CSS stylesheets dialog box with options for hi
© Select h1 in the left pane of the window. Click the Text tab as shown in figure 2.5. This will
show various style options like Font family, Font size, Line height, Color, Case, Alignment and
many more.
Cascading Style Sheets and Java script 7
Highlighted by Pragati Computers, M. 9904167671.Highlighted by Pragati Computers, M. 9904167671.
(Caan eee om faa
Font fanie 7
[=wisteraistyesheet unspecified
wt @ predetined:
“Times New Roman's Times seri
Usecustom fontfanily a
Fontslze
Uneheight: =8
oter:
Fortstle: unspectied. +
case uppercase. =
“Tent decorations
ez weight: [unspecfied. =
lonment: | center
‘verting
LUnethrough
‘underline
inking
‘THE QUICK BROWN FOX JUMPS
OVER THELAZY DOG
Figure 2.5 : Text tab
© We will now select the options as per the style required for hl. In the Font family section,
select the “predefined” radio button and choose "Times New Roman" from the drop down menu.
Choose "Uppercase" from the Case menu and "Center" from
the Alignment menu, Figure 2.5
shows the options selected. As you change the options, you can see the default text in the window
changes automatically according to the styles.
© To set the background color, select the Background tab. This will open the options for the
background as shown in figure 2.6.
e-w tx [rail ssagon0]
Color
Wwinternalstylesheat
at
meyer
A 1
ra
P coose te
cancel, |) 0K
Figure 2.6 : Background tab
Computer Studies : 12
Highlighted by Pragati Computers, M. 9904167671.Highlighted by Pragati Computers, M. 9904167671.
‘© Inthe Color option, click the color palette button. This opens Block Background Color dialog
box as shown in figure 2.7. Select the color of your choice and press OK. button.
Drees
Predefined colors:
F__Lastpicked color
Hue: jo i: J Hex: | #FFFFFF
saturation: [0 Green: | 255 Neme: | white
Brightness: | 255 Blue: | 255 ‘Transparent
Cancel
Figure 2.7 : Block Background Color dialog box
© Figure 2.8 shows the background tab after selecting the color.
Note : If you want to keep an image in the background then in the Image option, click on
"Choose file" and select the file for the background.
Pres
t & [Generat | Text] Backaround [Borders [Box | Lists | Aural
olor: | 99H =
7 A 1
mace & chnose te
Figure 2.8 : Options selected in Background tab for hi
‘Cascading Style Sheets and Java script 29
Highlighted by Pragati Computers, M. 9904167671.© To set the border, select the Border tab. This will open the options for the border as shown
in figure 2.9. If you want to apply the same border on all the four sides, tick the checkbox
in front of the text "All four sides use same border style". You will see that only one option
"Top" will be enabled and all others are disabled. This is because; the effect made on a single
side will be applied on all the four sides. From the drop down menu of Style, select dotted.
You can also specify the width and the color of the border as per your choice. We can also
see the preview of the border style used by us. Press OK button.
vo oh & 1 & (Eeewall ert euetjomnl totes [oon] Aaa)
@ Al foursides wsesaneborderstule
site wide
Top: dates
ihe
Beton:
Let
Figure 2.9 : Options selected in Border tab for hi
There are more options available if you select the other tabs in the window. But in our example,
wwe require only the selected options for applying style to hl.
Click on the General tab. This will show the CSS code which is generated as shown in figure
2.10, If you know HTML coding you can also edit the code.
+4 [Cowal yen] eeceoronnd [order [oar |uaa anal]
Style rule
Selector: ht
border-styie: dotted
background