110 likes | 196 Views
Applying Style. Creating an External Style Sheet. Ideal for giving all the pages on your Web site a common look Define all your styles in an external style sheet and then tell each page on your site to consult the external sheet, thus ensuring will have the same settings
E N D
Creating an External Style Sheet • Ideal for giving all the pages on your Web site a common look • Define all your styles in an external style sheet and then tell each page on your site to consult the external sheet, thus ensuring will have the same settings • Create a new text document in your text editor of choice • Define as many style rules as desired • Save as .css
Linking External Style Sheets • In the head section of each (X)HTML page in which you wish to use the style sheet • Type href=“url.css”
.html <head> <meta http-equiv=“content-type” content=“text/html;charset=utf-8”/> <title>Internal Style Sheet</title> <link rel=“stylesheet” type=“text/css” href=“base.css” /> </head> <body> <img src=“sunset.jpg” alt=“sunset” width=“200” height=“150” align=“left”/> <p> sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset </p> </body>
base.css img { color:red; border:solid; }
Creating Internal Style Sheet • Let you set the styles at the top of the (X)HTML document to which they should be applied
<head> <meta http-equiv=“content-type” content=“text/html;charset=utf-8”/> <title>Internal Style Sheet</title> <style type=“text/css”> img { color:red; border:solid; } </style> </head> <body> <img src=“sunset.jpg” alt=“sunset” width=“200” height=“150” align=“left”/> <p> sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset </p> </body>
Applying Styles Locally • For small scale • Safe way to begin
<body> <img src=“sunset.jpg” alt=“sunset” width=“200” height=“150” <style=“color:red; border:solid”> align=“left” /> <p> sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset, sunset </p> </body>
Adding comment to Style Rules /*Images will have a solid red border */ img { color:red; border:solid; }