Awp
Awp
TECHNIGAL PUBLIGATIONS® - An up thst for knowacigeAdvanced Web Programming 1-3 Refreshing Java Script and CSS * For the document cascading style sheet the style specification appear as the content ofa style element within the header of a document. Property Value Selector The type attribute tells the browser that what it is reading is text which is affected by the Cascading Style Sheet. The type specification is necessary because there is one more specification used in JavaScript. * The External style sheet makes use of style specification in the same manner as in document cascading style sheet. The most commonly used CSS properties are enlisted in the following table — Property Type Property Fonts font font-family font-size font-style font-weight @font-face Text letter-spacing line-height text-align textdecoration textindent Color and background background background-color background-image background-position background-repeat color TECHNIGAL PUBLIGATIONS® - An up thst for knowacigaAdvanced Web Programming 1-4 Refreshing Java Script and CSS Borders border border-width border-style border-top border-top-color border-top-width Spacing, padding padding-bottom, padding-left, padding- right, padding-top margin margin-bottom, margin-left, margin- right, margin-top height maxheight max-width min-height min-width width Layout bottom, left, right, top clear display float overflow position visibility z-index TECHNIGAL PUBLIGATIONS® - An up thst for knowncigaAdvanced Web Programming 1-5 Refreshing Java Script and CSS Lists liststyle liststyle-image liststyle-type EE) Location of Styles There are three levels of cascading style sheets - Inline style sheet ‘* Document level style sheet ‘© External level style sheet EEE] inline Style Sheet © The inline cascading style sheet is a kind of style sheet in which the styles can be applied to HTML tags. This tag can be applied using following rule - Tag { property: value } © Forexample : ‘
Here for the tag p two properties are used such as font-family and color and those are
associated with the values such as Arial and red respectively.
‘* Note that if we want to use more than one property then we have to use separator
such as semicolon. In the following HTML document we have used cascading style
sheet-
HTML Document [InlineStyle.htmi]
This is simple text This text is colored.
This page is created using Document Level Style Sheet
This line is aligned left and red colored.
Refreshing Java Script and CSS ‘The embedded style sheet is the most commonly used style sheet. This paragraph is written in Verdana font with font size of 14.
‘This is a blue colored line. TECHNICAL PUBLIGATIONS® - An up thst for knowaciga‘Advanced Web Programming 1-8 Refreshing Java Script and CSS This page is created using Document Level Style Sheet This line is aligned left and red colored paragraph is written in Vergana font with tone sige oF Script Explanation 1) _ In above program, we have defined all the selectors in the head sections only. And these HTML elements are then used along with the web page contents. 2) The setting defined in the selectors will affect the web page contents. For example we have defined the selector h2 as. =a oa ‘Selector { t-family:Arial; color:red; left:20px } ‘Value and then in the body section we have written - ‘ This line is aligned left and red colored. 3) Now as h2 defines font to be “Arial” with color as “red” having left alignment of 20 pixels, the sentence “This line is aligned left and red colored.” will be displayed in Arial font, which is red colored and aligned from left by 20 pixels. Surely we can see this effect on our web browser. EEE] External Stylesheet ‘* Sometimes we need to apply particular style to more than one web documents in such cases external style sheets can be used. TECHNIGAL PUBLIGATIONS® - An up thst for knowiacigeAdvanced Web Programming 1-9 Refreshing Java Script and CSS ‘© The central idea in this type of style sheet is that the desired style is stored in one .ess file. And the name of that file has to be mentioned in our web pages. ‘Then the styles defined in .css file will be applied to all these web pages. © Here is a sample program in which external style sheet is used. Step 1: Create an HTML document HTML Document{ExtCSS.htm]‘The External style sheet is the compact representation of Cascading Style Sheets. ‘This paragraph is written in Monotype Corsiva font with font size of 14.
‘This is a blue colored line.The links with a target attribute gets a RED background:
‘ Google Output ([ditestintnl x cS © @ file///c:/tes.html Ow) do) = ‘The links with a target attribute gets a RED background: Google Facebook Contextual Selector * "Contextual selectors” in CSS allow you to specify different styles for different parts of your document. + You can assign styles directly to specific HTML tags, or you can create independent classes and assign them to tags in the HTML. TECHNIGAL PUBLIGATIONS® - An up thst for knowaciga‘Advanced Web Programming Refreshing Java Script and CSS For example ~This line is in bold face with the color ofthe text - blue
Good Bye
/eijtestinten! €)> SO fieyj//a:/est.htmi OW) » ‘This line is in bold face font This line is in bold face with the color of the text - blue Good Bye EE Background Using background-image property an image can be set as background. HTML Document{Backimg.htmi]‘The Vicorial waterfall is one of the greatest waterfalls in the world. It lies on the Zimbezi river which is between the border of Zambia and Zimbabwe. ‘The Victoria fall can be seen from 25 to 40 miles away. ‘The roaring of the water can be heard from a long distance. ‘The native people call it as “mosi-oa-tunya”, that means “smoke that thunders”. Victoria falls was discovered by David Livingstone in 1855. ‘The falls were named in honor of Queen Victoria.
‘Twinkle, twinkle, litle star, How I wonder what you are.Up above the world so high, Like a diamond in the sky.Twinkle, twinkle, little star, How I wonder what you are! TECHNICAL PUBLIGATIONS® - An up thrust for knowacigaAdvanced Web Programming 1-22 Refreshing Java Script and CSS When the blazing sun is gone, When there's nothing he shines upon,Then you show your little light, ‘Twinkle, twinkle, through the night. ‘Twinkle, twinkle, little star, How I wonder what you arel In the dark blue sky so deep Through my curtains often peep For you never close your eyes Til the morning sun does rise ‘Twinkle, twinkle, little star How I wonder what you are Twinkle, twinkle, little star How I wonder ‘what you are
EEG Color and Color Properties Different browsers have different ability to deal with the colors. In the next subsequent sections we will discuss how to use colors using CSS. EEX] color Groups There are three groups of colors. Those are as given below - 1, This is the smallest group of colors. In this group there are 16 colors. These are named colors. The colors in this group are enlisted as follows - SrNo. ColorName Hexadecimal Value 1 black ‘000000 a red FFO000 3 lime OOFFOO 4 blue 000FF 5 yellow FEFFOO 6 fuchsia FFOOFF 7 aqua OOFFFF 8 white FFFFFF 9 silver ‘cococo 10 gray ‘808080 1 maroon ‘800000 12 purple 800080 TECHNIGAL PUBLIGATIONS® - An up thrust for knowacigaAdvanced Web Programming 1-23 Refreshing Java Script and CSS 13 green 008000 4 olive 808000 15 navy 000080 16 teal 08080 These colors get displayed as it is on the web browsers. And all the web browsers support these colors. 2. There is a set of 216 colors which is called web palette. The elements of such colors are red, green and blue. The values of these elements can be 00, 33, 66, 99, CC and FF. 3. There are 16 millions colors. These are 24-bit colors. Syntax : Color : colorname : EEA Color Properties Using color property we can set the foreground color and using background-color the background color can be set. The use of these properties is shown in XHTML document. HTML Document{colorProperties.htmi]Programming the Web
‘Programming the Web
Programming the Web
Output 1B Fon Woah Doms“ Wedows inert oer QO = [er over Samp ronewentn! Faveites | @) se (2) Get More Above B Fonteighe Demo Bet DT Re Pager Saye Programming the Web Programming the Web Programming the Web FJ Font Shorthands We can specify more than one font properties in a list For example HTML Document[Fontshrthnd.htm!]I Love my Countrylll
@ Font Properties - Windows Internet Explorer GO = Fi overt compesronsnninarent =]%1 x] ors He Faves | Bp B)Suageted Sts = ) Get Mom Adore x (Boni cpa [| Rr Be Pager sey I Love my Country!!! iM Computer | Protected Mode: OFF Text Decoration Using text decoration property we can include special features in the text. Various properties of text decoration are © underline * overline * line-through HTML Document{TxtDecor.htmi]This text is having linethrough
‘This text is having overline
‘This text is a normal text
Output @ Tex Decorstion - Windows Intemet Explorer He 0) ov empetnadecacsart —~ 145] x] Peres] Be Favorites | Qe (2) Suggested Sites» ) Get More Add-ons ~ @ tex decoction MB ~ e Pager satay This tecti This texts having overine This text is having underline This text is a nommal text MM Computer| Protectes Moue: OFF EY Alignment of Text Using cascading style sheets we can align the text. This alignment can be done using following properties such as - Property Value Meaning text-align left Aligning the text to the left. text-align right Aligning the text to the right text-align center Alignment of text at the text-indent value in inches Desired indentation of the text canbe applied. TECHNIGAL PUBLIGATIONS® - An up thst for knowncigeAdvanced Web Programming 32. Refreshing Java Script and CSS Following is script which uses various text alignment properties. HTML Document[TextAlignCSS.htm!]
Output
1B ord Lk Dee Windows hier pee
QO [eo or sete
he Fovomes |e @) Sugoestes sues +g) Ge Mote |
B Vnordaed it Dane sey
cles] x]|P tveeveon P =|
Significance of Vegetables
+ Cant
© Teimproves appearance of skin har and nal
« Ieimproves eyesight
© Iteegults Blood sugar
+ Cuamniber
* Tels wef in ver ceases
+ Ircomrole diabetes
* Spinach
© Teserves at an anti-cancer agent,
+ is ani-aging vegetable.
4 Its arch source of Viana A and C.
TECHNIGAL PUBLIGATIONS® - An up thst for knowecigaAdvanced Web Programming 1-36 Refreshing Java Script and CSS
We can also display small images as the list item bullet. For example
HTML Documenttist3.html]
‘
‘
TECHNIGAL PUBLIGATIONS® - An up thst for knowecigeAdvanced Web Programming 1-39 Refreshing Java Script and CSS
Boas bore Wee ape Epo
Oa oven toreetne —
Se Fovontes | 3B) 0
Bedeedindene
Vitamins in Fruits and Vegetables
1. Frit
1 Compa otiee Mode OF
Ei Responsive Design
Definition : “Responsive design” refers to the idea that your website should
display equally well in everything from widescreen monitors to mobile phones.
Itis called responsive web design because you can resize, hide, shrink, enlarge, or
move the contents of the web page to make it look good on any screen.
The responsive web design makes use of HTML and CSS only. It is neither a
program nor a JavaScript.
Using the responsive design approach the web developer can give the best
experience for all the user. For example -
TECHNIGAL PUBLIGATIONS® - An up thst for knowacigaAdvanced Web Programming 1-40 Refreshing Java Script and CSS
Desktop Mobile ohone
Tablet
Fig. 4.9.4 Responsive Layout for Different Devices
‘© There are four key components that make responsive design work -
© Liquid Layouts
© Scaling Images to the viewport size.
©. Setting viewports via tag.
© Customizing the CSS for different viewports using media queries.
‘* Making the use of liquid layouts means specifying the widths in percentage. This is
the most obvious part of any responsive web design approach. Scaling images to
the viewport size means you have to specify following rule:
img {
‘Width:100%;
+
* It only shrinks or expands the visual display of the image to fit the size of the
browser window, never expanding beyond its actual dimensions.
EEEI setting Viewports
‘© Viewport means user's visible area of web page.
‘© The viewport varies from mobile phone to desktop computers.
* HTMLS allows the web developer to take control over the viewport using
tag.
TECHNIGAL PUBLIGATIONS® - An up thst for knowacigaAdvanced Web Programming 1-41 Refreshing Java Script and CSS
‘* Following line must be included in your HTML document to set the viewport :
aN
‘Sets the intial zoom
Gives browser the 8
instruction to control Sets width of page as per level when the page is
dimension of web page cialoserrede ‘rat loaded by he
Fig. 1.9.2
The HTML document structure will be :
* By setting the viewport in above manner, the page is telling the browser that no
scaling is needed, and to make the viewport as many pixels wide as the device
screen width.
‘© This means that if the device has a screen that is 320 px wide, the viewport width
will be 320 px; if the screen is 480 px then the viewport width will be 480 px.
EEE] Media Queries
‘* Another key component of responsive web design is media queries. Media queries
is for different style rules for different size devices such as mobiles, desktops and so
on.
‘* It uses the @media rule to include a block of CSS properties only if a certain
condition is true.
‘* For example - Following HTML document makes use of media queries for different
types of devices(such as mobile phones, tablets and desktops)
HTML Document