E N D
CSS SUNRAYS Technologies PUNE | INDORE | VADODARA | RAIPUR Email : hrd@sunrays.co.in URL : www.sunrays.co.in, www.sunraystechnologies.com
Our Books – www.sunilbooks.com www.sunrays.co.in
Cascading Style Sheets • CSS stands for Cascading Style Sheets. • CSS defines the look and feel of HTML elements. • Styles were added to HTML 4.0 to solve a problem. • External Style Sheets are stored in CSS files. • It is a way to define themes of your HTML Web Site. www.sunrays.co.in
Declaration of CSS • Each declaration of CSS consist of Property & Value pair • Properties are separated from their values by colons ( : ) • Pairs are separated from each other by semicolon ( ; ) color : red; font-size : 20px; www.sunrays.co.in
Simple Example <html> <head> <style> p{ color : red; font-size : 20px; } </style> </head> <body> <p>This is a paragraph</p> </body> </html> Output : This is a paragraph www.sunrays.co.in
Selector • Selectors are used to apply style to a particular markup. • Selectors are normally the HTML element. • Selector never starts with a number. • Selector never contains space. • Three types of Selector • Tag Selector • ID Selector • Class Selector www.sunrays.co.in
Tag Selectors • Tag Selector • p – paragraph • h – heading • a – hyperlink • ID Selector • #param • #wrapper • Class Selector • .menu • .title • .subtitle www.sunrays.co.in
Tag Selector • Tag selector is used to redefine existing HTML tags. • Selector is used when you want to change the formatting of existing tags. • Such as : • <h1> (heading 1) tag • <ul> (unordered list) tag. • <p>(paragraph) tag. • <a>(hyperlink) tag. www.sunrays.co.in
ID Selector • ID selector is used to specify a single, unique element. • ID selector uses the id attribute of the HTML element . • ID selector defines with “#”. • Do not start an ID name with a number. <style> #param{ test-align : center; font-size : 20px; } </style> <div id=“param”>……………</div> www.sunrays.co.in
Class Selector • Class selector is used to specify a style for group of elements. • Set a particular style for many HTML elements with the same class. • Class selector defines with ”.” <style> .title{ color : red ; font-size : 30px; } </style> <p class=“title”>……………</p> www.sunrays.co.in
Style Sheets • There are three ways to insert a style sheet • Inline Style • Internal Style Sheet • External Style Sheet www.sunrays.co.in
Inline Style • CSS is applied in every HTML tag by Inline style • For using Inline style, style attribute is used in relevant tag. • Style attribute can contain any CSS property. • For example: <p style="background: blue; color: white;">A new background and font color with inline CSS</p> www.sunrays.co.in
Internal Style Sheet • Internal is the basic & easy way to insert style in HTML • In Internal style, <style>…………</style> tag is added in the <head>…………</head> tag of HTML document. • Internal Style Sheet should be used when a single document has a unique style. www.sunrays.co.in
Internal Style sheet <html> <head> <style type="text/css"> p { color: red; } body { background-color: yellow; } </style> </head> <body> <p>Paragraph showing Internal style sheet</p> </body> </html> www.sunrays.co.in
External Style Sheet • External CSS is a file that contains only CSS code and is saved with a ".css" file extension. • This CSS file is then referenced in HTML using the <link> tag instead of <style> tag. • External style sheet is applied to many pages. • External style sheet can change the entire look of website by changing only one file. • External style sheet keeps the design & content separate. • We can reuse the CSS code. www.sunrays.co.in
External Style Sheet <html> <head> <link rel="stylesheet" type="text/css" href="test.css" /> </head> <body> <h3> A White Header </h3> <p> This paragraph has a blue font. The background color of this page is gray because we changed it with CSS! </p> </body> </html> www.sunrays.co.in
Example Source Code https://github.com/sunilbooks/SelfLearnJava www.sunrays.co.in
Thank You If you have any questions feel free to contact us : Email : hrd@sunrays.co.in URL : www.sunrays.co.in Next topic “JDBC” www.sunrays.co.in