150 likes | 409 Views
S t y l i n g your page (font type, font size, colors, text decoration, alignment, set margin, table padding, etc.). References: W3Schools (http://www.w3schools.com).
E N D
Styling your page(font type, font size, colors, text decoration, alignment, set margin, table padding, etc.) References: W3Schools (http://www.w3schools.com)
Styling your page(font type, font size, colors, text decoration, alignment, set margin, table padding, hypertext colors etc.) Overview: How #1 (Inline style) How #2 (internal style) How #3 (external style)
How to change the font or text attributes without using <font> tag since it’s deprecated? ? How
How #1 (Inline style) Previously, you learnt about style attribute applied to paragraph. Recall this example (from previous slide): <p style="color: red; font-family: arial; font-size: 14pt"> This is a paragraph </p> Notice the way of writing the style attribute (see the red text) is different from the way of writing other attributes. It can be lengthy... This attributes are called as CSS (cascading style sheet) properties.
How #1 (Inline style) <p style="color: red; font-family: arial; font-size: 14pt"> This is a unique paragraph with its own style. </p> This approach of doing style is called as Inline style An inline style should be used when a unique style is to be applied to a single occurrence of a html element such as to this unique paragraph.
How #2 (Use <style></style> html tag) • Use notepad, and do this Example: <html> <head> <style> h1 {color: red} h3 {color: blue} </style> </head> <body> <h1>This is header 1</h1> <h3>This is header 3</h3> </body> </html> <style> tag is a container tag, it must reside in <head> tag. Try to change the <h1> text attribute (such as color, font-family, font-size, text-align, text-decoration, etc) to different styles. Do figure out how to do that.
How #2 (Use <style></style> html tag) Add more styles (CSS properties) to <h1>, and test it out. • Use notepad, and do this Example: <html> <head> <style> h1 {color: red} h3 {color: blue} </style> </head> <body> <h1>This is header 1</h1> <h3>This is header 3</h3> </body> </html> h1 { font-family:"times new roman"; font-size:20pt; text-align:center; text-decoration:underline; color:green; }
How #2 (Use <style></style> html tag) • Use notepad, and do this Example: <html> <head> <style> h1 {color: red} h3 {color: blue} </style> </head> <body> <h1>This is header 1</h1> <h3>This is header 3</h3> </body> </html> For this approach, we called it as: Internal Style Sheet An internal style sheet should be used when a single html document has a unique style. You define internal styles in the head section with the <style> tag.
How #3 (Use external style sheet) • An external style sheet is ideal when the style is applied to many pages. • With an external style sheet, you can change the look of an entire Web site by changing one file (what file is that? Anyone can guess??). • Each html page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section.
How #3 (Use external style sheet) • Example: <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head> An external file which contains CSS properties written by using notepad, but with the extension name “XXX.css”
How #3 (Use external style sheet) • Example of the contents for “mystyle.css”: body { color: black; background-color: #ffffff; } h1,h2,h3 { font-family: verdana, arial, "sans serif"; } p, table { font-family: verdana, arial, "sans serif"; margin-left: 10pt; } a:link {color:darkgreen} a:visited {color:grey} a:active {color:darkgreen} a:hover {color:mediumblue}
How #3 (Use external style sheet) • You can try this example now!!!