80 likes | 165 Views
Cascading Style Sheet Basics. Pepper. Looking at the HTML. See the <> surrounding tags See head, body, paragraph, header See the ending tags</…> See the list <ul> </ul> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>A page with no Styles</title> </head>
E N D
Cascading Style Sheet Basics Pepper
Looking at the HTML See the <> surrounding tags See head, body, paragraph, header See the ending tags</…> See the list <ul> </ul> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>A page with no Styles</title> </head> <body> <!-- Main content --> <h1>A page with no styles</h1> <p>Welcome to my page with no Styles, only HTML coding. <p>I know the links go nowhere, but I will soon put those links into a nice table. They would go somewhere if they pointed to pages that existed. <p>This page is just a normal page. <!-- Sign and date the page, it's only polite! --> <address>Made <br> 6/2007</address> <!-- Site navigation menu --> <ul > <li><a href="index.html">Home page</a> <li><a href="links.html">Links</a> </ul> </body> </html> http://home.adelphi.edu/~pe16132/csc170/web/step/css/css.html
Simple Style inside an HTML tag • Inside the <>, put a style = “something” Change from: <h1>A page with no styles</h1> TO: <h1 style="color:blue;text-align:center">A page with no styles</h1> • Pairs of Property name: choice • List of properties: http://www.w3schools.com/cssref/default.asp
Navigation Bar Styling Goal: set the physical location (em’s over from the left) of the body of the page, and set the physical location (em’s over from the left) of the navigation words. To set the list of navigation links to always start in the upper left: <ul style = " position: absolute; top: 2em; left: 1em; width: 9em"> To pad 11 ems over from the left, set your body to: padding-left: 11em; <body style = “padding-left: 11 em”>
Move your style up to the header • Same style can move up to the header as an internal style sheet • For UL, we will want some lists on our page not to be in the upper left, so make it a type of UL with ul.navbar <head> <style type="text/css"> body {padding-left: 11em; } ul.navbar { list-style-type: none; padding: 0; margin: 0; position: absolute; top: 2em; left: 1em; width: 9em } </style> </head> For UL, to get the .navbar class : <ul class="navbar"> http://home.adelphi.edu/~pe16132/csc170/web/step/css/css3.html
Move Out to External Style Sheet • Inside the <head> </head> : <link rel="stylesheet" href="mystyle.css"> The external stylesheet would contain exactly what was in the internal style sheet: body {padding-left: 11em;} ul.navbar{ list-style-type: none; padding: 0; margin: 0; position: absolute; top: 2em; left: 1em; width: 9em }
CSS Guides • Examples of each level of styling http://home.adelphi.edu/~pe16132/csc170/web/step/csslinks.htm • Tutorials: • good tutorial • tutorial 2 - with • command reference from w3schools • more on ids • more on classes • positioning navigation bars
Priority of Style Levels HTML pages can have the same style repeated in four forms in one page. It has to know which takes priority. Here is the order, with the highest number being the one that will be used. • Browser default • External style sheet • Internal style sheet (inside the <head> tag) • Inline style (inside an HTML element) called inline