├── .gitignore ├── 1 - Structure ├── part1.html └── part2.html ├── 2 - Tags ├── page1.html ├── page2.html └── tables.html ├── 3 - Styles ├── style1.html ├── style2.html └── style3.html ├── 4 - Head ├── blend.jpg ├── can.jpg ├── cooking.html ├── cut.jpg ├── done.jpg ├── flatten.jpg ├── ingredients.jpg ├── introimage.jpg ├── oven.jpg ├── package.jpg └── water.jpg ├── 5 - Layout ├── aboutpage.html ├── contactpage.html └── homepage.html ├── 6 - Linking ├── home.html └── main.css ├── 7 - Project ├── example.css ├── example.html ├── index.html └── main.css ├── README.md └── cpbm.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | .project -------------------------------------------------------------------------------- /1 - Structure/part1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Website 6 | 7 | 8 | 9 | Hello, World! 10 | 11 | 12 | -------------------------------------------------------------------------------- /1 - Structure/part2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Website 6 | 7 | 8 | 9 |

Hello, world!

10 |

This is a paragraph of text, and it's inside a p tag.

11 |

This is another block of text. Inside another p tag. Mind blowing.

12 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /2 - Tags/page1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Website 6 | 7 | 8 | 9 |

This is Page 1!

10 | 11 |

12 | We're going to play so much on this page. It will be so fun. You have no 13 | idea. HTML is a party. 14 |

15 | 16 | 17 | -------------------------------------------------------------------------------- /2 - Tags/page2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Website 6 | 7 | 8 | 9 |

This is Page 2!

10 | 11 | 12 | 13 |

Hey sexy.

14 |

You did it. Click here to go back to Page 1.

15 | 16 | 17 | -------------------------------------------------------------------------------- /2 - Tags/tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Website 5 | 6 | 7 |

Check out that table.

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
First HeaderSecond Header
First Row, First CellFirst Row, Second Cell
Second Row, First CellSecond Row, Second Cell
23 | 24 | 25 | -------------------------------------------------------------------------------- /3 - Styles/style1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Website 6 | 7 | 8 | 9 |

How To Be Attractive

10 |

An overview by me.

11 |

For you.

12 |

Because I care.

13 | 14 | 15 | -------------------------------------------------------------------------------- /3 - Styles/style2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Website 6 | 7 | 8 | 9 |

How To Be Attractive

10 | 11 |

12 | All it takes is makeup and cool clothes, and you're most of the way there. 13 |

14 | 15 |

Let's talk numbers. What are the steps to be more good looking?

16 | 17 |
    18 |
  1. Buy makeup and trendy clothes
  2. 19 |
  3. 20 | Make a viral YouTube video shaming companies for telling us this is how 21 | to be attractive 22 |
  4. 23 |
  5. 24 | Pay attention to the comments, someone on there will probably call you 25 | hot 26 |
  6. 27 |
  7. Relish in the joys of the internet
  8. 28 |
29 | 30 | I'm just so happy that you know CSS now. 34 | 35 | 36 | -------------------------------------------------------------------------------- /3 - Styles/style3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Website 5 | 6 | 7 | 8 | 9 |

Poetry

10 | 11 |

Check out these incredible poems!

12 | 13 |
14 | 15 |

16 | Pearls 17 |

18 |

19 | Sarah Baugh 20 |

21 |

22 | The world is your oyster 23 |
24 | What does that mean? 25 |
26 | Is there a pearl hidden in every dark place? 27 |
28 | Or is the world only what we want it to be 29 |
30 | If we have the pearls to pay for it? 31 |
32 | If we pry something open 33 |
34 | That is shut tightly 35 |
36 | And is dark 37 |
38 | Mysterious 39 |
40 | Will we always find something beautiful? 41 |
42 | 43 | Not ever oyster holds a pearl. 44 |
45 | 46 | Is it the promise of something beautiful 47 |
48 | That keeps us searching for oysters 49 |
50 | In this world? 51 |
52 | 53 | Not every pearl is in an oyster. 54 |
55 |

56 | 57 |
58 | 59 |

60 | Real Happiness 61 |

62 |

63 | Shashikant Nishant Sharma 64 |

65 |

66 | Happiness lies in good health
67 | Not in accumulation of wealth
68 | Happiness lies in caring for others
69 | Like dear friends and brothers
70 | Happiness lies in sharing
71 | Not is amassing
72 | Happiness is the state of mind
73 | Nowhere else you can find
74 | Enjoy the moment, live the life
75 | Settle score and end the strife
76 | Happiness is the journey not destination
77 | Happiness Is doing what is your fascination
78 | Happiness is doing what you like
79 | Sleeping, walking, running and riding a bike
80 | Happiness will come near
81 | When you will venture without fear
82 | Render service that you can
83 | Live a life that adorn a man
84 |

85 | 86 |
87 | 88 |

89 | Thanks for reading! 90 |

91 | 92 | 93 | -------------------------------------------------------------------------------- /4 - Head/blend.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/blend.jpg -------------------------------------------------------------------------------- /4 - Head/can.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/can.jpg -------------------------------------------------------------------------------- /4 - Head/cooking.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Cooking Website 5 | 6 | 7 |

8 | How to make your own Cheesy Cracker Snacks 9 |

10 | 11 | Make these tasty snacks! 12 |

13 | Today, we're going to teach you how to make some delicious cheesy snacks, 14 | fun for the whole family. 15 |

16 | 17 | Ingredients 18 |

19 | You will need the following ingredients: 20 |

21 | 44 | 45 |
46 | 47 | The can 48 |

49 | The first step is cutting out the shapes of your crackers from the 50 | aluminum can. Cut a thin strip and, then tape the edges together with 51 | clear packing tape. 52 |

53 | 54 |
55 | 56 | Process THIS 57 |

58 | Begin combining everything, except the water, in a food processor until 59 | the dough looks like sand. 60 |

61 | 62 |
63 | 64 | Adding water 65 |

66 | Next, pulse in the water, 1 tablespoon at a time, until combined. 67 |

68 | 69 |
70 | 71 | Package this 72 |

73 | Remove the dough from the processor and form into a small, tidy package. 74 | Wrap in plastic and chill for 20 minutes. 75 |

76 | 77 |
78 | 79 | Roll out 80 |

81 | Once chilled, roll out and flatten the dough. 82 |

83 | 84 |
85 | 86 | Cut this 87 | Cook this 88 |

89 | Place crackers on a lined cookie sheet and bake at 350F for about 15 90 | minutes. 91 |

92 | 93 |
94 | 95 | Boo yah 96 |

97 | And, you're done! 98 |

99 | 100 |

101 | This recipe was lovingly ripped off of 102 | The Tasty Kitchen. 103 |

104 | 105 | 106 | -------------------------------------------------------------------------------- /4 - Head/cut.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/cut.jpg -------------------------------------------------------------------------------- /4 - Head/done.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/done.jpg -------------------------------------------------------------------------------- /4 - Head/flatten.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/flatten.jpg -------------------------------------------------------------------------------- /4 - Head/ingredients.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/ingredients.jpg -------------------------------------------------------------------------------- /4 - Head/introimage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/introimage.jpg -------------------------------------------------------------------------------- /4 - Head/oven.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/oven.jpg -------------------------------------------------------------------------------- /4 - Head/package.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/package.jpg -------------------------------------------------------------------------------- /4 - Head/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cassidoo/HTML-CSS-Tutorial/4aa7ea200c9b864631fd2eef1249dacc824b40fe/4 - Head/water.jpg -------------------------------------------------------------------------------- /5 - Layout/aboutpage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | About Me 5 | 6 | 7 | 8 | 9 |
10 | This is a header 11 |
12 | 20 |
21 |

About me

22 |

A tragedy

23 |

24 | Now, this is the story all about how my life got flipped-turned upside 25 | down and I'd like to take a minute, just sit right there I'll tell you 26 | how I became the prince of a town called Bel Air.
27 | In West Philadelphia, born and raised on the playground is where I spent 28 | most of my days chillin' out, maxin', relaxin' all cool and all shootin' 29 | some B-ball outside of the school.
30 | When a couple of guys who were up to no good started makin' trouble in 31 | my neighborhood I got in one little fight and my mom got scaredand said, 32 | "You're movin' with your aunty and uncle in Bel Air."
33 | I begged and pleaded with her the other day but she packed my suitcase 34 | and sent me on my way she gave me a kiss and then she gave me my ticket 35 | I put my Walkman on and said, "I might as well kick it!"
36 |

37 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /5 - Layout/contactpage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Contact Me 5 | 6 | 7 | 8 | 9 |
This is a header
10 | 15 |
16 |

Here's how you can contact me!

17 | 21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /5 - Layout/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Website 5 | 6 | 7 | 8 |
This is a header
9 | 14 |
15 | "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 16 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim 17 | veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 18 | commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 19 | velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 20 | cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id 21 | est laborum." 22 |
23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /6 - Linking/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Website 5 | 6 | 7 |
This is a header
8 | 13 |
14 | "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 15 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim 16 | veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 17 | commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 18 | velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 19 | cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id 20 | est laborum." 21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /6 - Linking/main.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | } 4 | body { 5 | font-family: Arial; 6 | height: 100%; 7 | margin: 0px; 8 | } 9 | .header { 10 | background-color: #99b5dd; 11 | position: fixed; 12 | top: 0px; 13 | width: 100%; 14 | height: 60px; 15 | padding: 0px 10px; 16 | font-size: 50px; 17 | z-index: 10; 18 | } 19 | .menu { 20 | background-color: #de90b1; 21 | height: 100%; 22 | width: 15%; 23 | position: fixed; 24 | left: 0px; 25 | top: 60px; 26 | padding: 10px 0px 0px; 27 | text-align: center; 28 | z-index: 5; 29 | } 30 | .content { 31 | height: 200px; 32 | position: absolute; 33 | top: 60px; 34 | left: 15%; 35 | padding: 10px; 36 | z-index: 0; 37 | } 38 | .footer { 39 | background-color: #0f215d; 40 | position: fixed; 41 | bottom: 0px; 42 | height: 60px; 43 | width: 100%; 44 | z-index: 10; 45 | } 46 | -------------------------------------------------------------------------------- /7 - Project/example.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | } 4 | body { 5 | font-family: Arial; 6 | height: 100%; 7 | margin: 0px; 8 | } 9 | a { 10 | color: red; 11 | } 12 | img { 13 | float: right; 14 | width: 200px; 15 | } 16 | p span { 17 | font-weight: bold; 18 | } 19 | .header { 20 | background-color: #99b5dd; 21 | position: fixed; 22 | top: 0px; 23 | width: 100%; 24 | height: 60px; 25 | padding: 0px 10px; 26 | font-size: 50px; 27 | z-index: 10; 28 | } 29 | .content { 30 | position: absolute; 31 | top: 60px; 32 | padding: 10px; 33 | margin-bottom: 60px; 34 | z-index: 0; 35 | } 36 | .footer { 37 | background-color: #0f215d; 38 | position: fixed; 39 | bottom: 0px; 40 | height: 60px; 41 | width: 100%; 42 | z-index: 10; 43 | } 44 | -------------------------------------------------------------------------------- /7 - Project/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Susan's Website 5 | 6 | 7 | 8 |
9 | Susan Baugh 10 |
11 |
12 |

Welcome!

13 |

14 | Thanks for stopping by! My name is Susan and I love art, learning about 15 | energy and renewable resources, and playing Candy Crush.
16 | Please have a look around and check out my projects and work!
17 |

18 | I'm Susan 19 | 20 |

Publications

21 | 22 |

Presentations

23 | 24 | Construction of the Belo Monte Hydroelectric Power Plant in the Amazon 25 |
26 | 27 | Microfluidic Devices for Medical and Energy Applications
28 | 29 |

Publications

30 | 31 | Paper-based Microfluidics for Energy Applications
32 | 33 | How to Destroy Candy Crush in 5 Easy Steps
34 | 35 |

Contact Me

36 | 37 |

Email susan@example.com

38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /7 - Project/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Website 6 | 7 | 8 | 9 | 10 | 11 | 18 |

[Your name here]

19 | 20 |

Let's talk about me.

21 | 22 | 23 | -------------------------------------------------------------------------------- /7 - Project/main.css: -------------------------------------------------------------------------------- 1 | /* 2 | Here, you are going to make the CSS for your project! 3 | That's right, I'm not going to help you. 4 | You're free. 5 | 6 | There's so many jokes I could make here but I know you just want to work. 7 | So you do that. 8 | 9 | I'll be here. 10 | 11 | Checking you out. 12 | 13 | O_O 14 | */ 15 | 16 | body { 17 | /* Notice that you can have your curly braces on the same line as your selector. Your preference. */ 18 | } 19 | 20 | h1 { 21 | } 22 | 23 | p { 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HTML+CSS Tutorial 2 | ================= 3 | 4 | ### Who 5 | 6 | I'm Cassidy. I'm a engineer and I've been teaching myself HTML, CSS, and other web development and scripting for over 15 years. 7 | And I want to teach you now. 8 | Because you're good looking. 9 | And because it's useful. 10 | 11 | ### What 12 | 13 | In this tutorial, we'll start from the very beginning. You don't need to know anything about HTML and CSS or anything about code to start. I'll include some tutorial files for you to play with and check out. 14 | 15 | ### When 16 | 17 | Now. Or whenever. I'm not planning on taking this down anytime soon. But you are only limited by your own schedule. Or set free by it. Whatever. 18 | 19 | ### Where 20 | 21 | On a computer. Here. 22 | 23 | ### Why 24 | 25 | Because this stuff is important. Whether you're a business person formatting your emails, an aspiring web designer wanting to get your feet wet, or just someone who is interested and hasn't tried any sort of coding, scripting, or programming before, **HTML and CSS are an essential part** of your learning curve. 26 | 27 | ## Table of Contents 28 | * [HTML](https://github.com/cassidoo/HTML-CSS-Tutorial#html-time-lets-go) 29 | * Editors 30 | * Tag Structure 31 | * Text Structure 32 | * Links 33 | * Other tags 34 | * Images 35 | * Line Breaks 36 | * Tables 37 | * Making Things Gorgeous The Wrong Way 38 | * Colors 39 | * Width and Height 40 | * Borders 41 | * Text Styles 42 | * The `` tag 43 | * Putting it all together so far 44 | * [CSS](https://github.com/cassidoo/HTML-CSS-Tutorial#css-is-magical-and-now-youre-gonna-learn-it) 45 | * Classes and IDs and other Segregation 46 | * Classes 47 | * IDs 48 | * Other Segregation 49 | * The `` tag 50 | * The `
` tag 51 | * Background color 52 | * Floating 53 | * Positioning 54 | * Margins and Padding 55 | * Z-Index 56 | * The `` Tag, Comments, and other Developer Joys 57 | * The `` tag 58 | * Commenting 59 | * HTML Comments 60 | * CSS Comments 61 | * Other Developer Joys 62 | * Forms 63 | * HTML5 and CSS3 64 | * How To Meet Losers (Get it? HTML Jokes are the best...) 65 | * [Final Project!](https://github.com/cassidoo/HTML-CSS-Tutorial#final-project) 66 | * And now, the end is near 67 | 68 | ## HTML Time. Let's Go. 69 | 70 | ### Editors 71 | 72 | So the first thing you'll need is an editor to edit your jazz. There's tons of options out there. 73 | 74 | * Notepad/TextEdit (that's right, the stupid thing that comes on your computer) - This is about as basic as you can get. It's totally okay if you want to use this, but I recommend one of the editors below just so you can see code highlighting (which will help you out later on). But, if you want to be a purist, this'll work just fine. 75 | * [Visual Studio Code](https://code.visualstudio.com/) - This is what I typically use. It's open source and has TONS of extensions available. 76 | * [Sublime Text](https://www.sublimetext.com/) - This is a pretty popular option. Very clean interface. 77 | * [CodePen Projects](https://codepen.io/project) - This is an in-browser code editor, so you can code directly within the web browser, no downloads required. :) 78 | * [Glitch](https://glitch.com/) - This is another in-browser code editor. It is meant for larger projects, but it's nice to not have to download anything! 79 | * [Notepad++](http://notepad-plus-plus.org/) - This is just one step up from Notepad. But it's pretty dece. Code highlighting is in it, and nothing else too fancy, which is what I like about it. 80 | 81 | There's a bunch of others [listed here](http://en.wikipedia.org/wiki/List_of_HTML_editors), I just listed the ones I've used and liked! 82 | 83 | ### HTML Tag Structure 84 | 85 | Here is a barebones HTML page, about as simple as you can get. You can open it up in the **1 - Structure** folder in the file part1.html. If you were to open the file in your favorite browser (which you can do, go ahead), you'll see a plain webpage with the title "My Website" and the words, "Hello, World!" written on the page. 86 | 87 | ```html 88 | 89 | 90 | 91 | 92 | My Website 93 | 94 | 95 | 96 | Hello, World! 97 | 98 | 99 | ``` 100 | 101 | So, what are we looking at here? 102 | HTML, short for *HyperText Markup Language*, consists of these things called tags, which are words written between `<` and `>` characters, like ``. All tags (with just a few exceptions that we'll talk about later) have a matching closing tag, which has the same name as the opening tag, except that it contains `/` after the first `<`, like ``. 103 | 104 | For example, `` is one tag and the closing tag for it is ``, same with `` and `` and `` and ``, and so on. You get it. 105 | The opening and closing tags together are an *element* (which also includes everything written in it). For example, `My Website` is one element. The text inside an element, in the title case, `My Website`, is called the *content* of an element. 106 | 107 | Tags organize your page and tell the browser what your page consists of. There's tons of tags out there, some that you may never use. 108 | Here's some lists of tags if you really care to see all of them at this point: 109 | * [HTML Dog Tag List](https://www.htmldog.com/references/html/tags/) 110 | * [W3Schools Tag List](https://www.w3schools.com/tags/default.asp) 111 | * [Quackit HTML Tag List](https://www.quackit.com/html/tags/) 112 | 113 | So, if you look at our example, you can also put tags inside other tags (like we did with the `` tags inside the `<head>` tags). This is called *nesting* elements. 114 | In this case, we would say that the `<head>` *contains* the `<title>`. Sometimes when you have a lot of nested tags, it's hard to keep track, so you have to format your code with spacing, as shown. Typically, inner tags are spaced more than their outer tags (just as `<title>` is indented further than `<head>`). 115 | 116 | Let's take a look again at part1.html in the **1 - Structure** folder. You'll notice that the first line has `<!doctype html>`. Every HTML document and website has to have this special tag, as it tells the browser what language we're using. This is one of those special tags I mentioned that doesn't need a closing tag. 117 | 118 | On the second line, you can see a `<html>` tag. Everything in the website is contained by this tag, and the last line of your entire document will always be `</html>`. 119 | 120 | Inside `<html>`, there are two elements: `<head>`and `<body>`. Contained in `<head></head>`, we will put all kinds of information for the browser that the user doesn't necessarily need to see. For now, we just have `<title>`. The content of `<title>` will be used for the name of the tab of the browser, and also by search engines. 121 | 122 | On the other side of the planet, we have `<body></body>`. Everything visible to the user is contained in these tags. Right now, all that consists of is "Hello, World!" Let's change that for fun. Replace "Hello, World!" with your own text in your favorite HTML editor, and then open the page in your browser. Neat! 123 | 124 | ### Structuring text 125 | 126 | Let's get juicy. We're going to talk about some new tags for structuring your text. Because you're not going to want just one style of text throughout your whole website, right? 127 | 128 | Check out part2.html in the **1 - Structure** folder. The tags that we'll be talking about here are `<h1>`, `<p>`, `<ul>`, and `<li>`. Open the file in the browser to try and understand what the heck is going on. 129 | 130 | Now, let's talk about it. 131 | 132 | First, we have `<h1>`, which adds a *heading* to our website. Basically, a heading is just text with a bigger font. But still. Important. We'll soon learn how to adjust any and all font sizes, but not yet. Just know that your headings should be in `<h1>` tags. Also, if you have a smaller heading, or *sub-heading*, you could use `<h2>`, which is smaller than `<h1>`, but bigger than regular text. You can keep going with more numbers until you reach `<h6>`, with each heading a bit smaller than the previous. Try adding some subheadings underneath our current heading! 133 | 134 | Next, we have `<p>` tags. `<p>` adds a *paragraph* of text to our website, which are blocks of text that have some space before and after them. Edit the text in the paragraphs given, and add your own to see what I mean! 135 | 136 | And finally, we have `<ul>`. `<ul>` means a bulleted list (also known as an *unordered list*), where every `<li>` is an item in that list (called a *list item*). But what if you want a numbered list? You could change `<ul>` to `<ol>` (and don't forget its closing tag), it's that simple! `<ol>` is an *ordered list*, which has numbers instead of bullet points, and that is truly the only difference. Add some list items (`<li>`) to the list (make sure you stay inside the `<ul>` tags), and then change your `<ul>` tags to `<ol>`! 137 | 138 | ### Links 139 | 140 | Links are what makes the world/Internet go 'round. Seriously. So, let's learn about them. 141 | 142 | Links are made with the `<a>` tag, which stands for *anchor*. 143 | 144 | Open up the **2 - Tags** folder, and add this piece of code right after your heading in page1.html: 145 | 146 | ```html 147 | <p>This paragraph <a href="http://www.lalalalalalalalalalalalalalalalalala.com/">has a totally awesome link.</a></p> 148 | ``` 149 | 150 | Open page1.html in a browser and click on it! BEAUTIFUL. 151 | 152 | Okay, so let's take a look at this. First of all, you can see the `<a>` tag there contained in the paragraph. Beautiful. 153 | But what's that funky milk `href=`? Well, that syntax called an *attribute*. Attributes change the way a tag works, and are not visible to the website's user. You only add attributes to the opening tag, not a closing tag. Tags can have multiple attributes, for example: 154 | 155 | ```html 156 | <tag attribute="value1" attribute2="value2">Content of tag</tag>` 157 | ``` 158 | 159 | Got it? Good. You're so good looking. 160 | 161 | So, anyway, the attribute 'href' tells us where the link is going to go when the user clicks on it (and for those curious, it stands for *hyperreference*). Try adding some more links to the page to different websites! 162 | 163 | Also, one thing you should note: Links don't have to be in `<p>` tags like I put above. You could put them in `<li>` tags in a list, `<h1>` tags for a linking header, or completely on their own! 164 | 165 | #### Adding links to other pages in your website 166 | Let's just say you have a fully functioning website called fakewebsite.com. You have your homepage and your "Contact Us" page in the same directory or folder. 167 | 168 | Normally when a beginner links to different pages on their website, they just make links that look like `<a href="http://www.fakewebsite.com/index.htmL">Home</a>` and `<a href="http://www.fakewebsite.com/contactus.htmL">Contact Us</a>`. 169 | 170 | This is okay. BUT, you can do better. So, what if you change your domain name to reallyfakewebsite.com? When you edit your HTML, you'd have to edit every single one of the links to match the new domain. That's gross. There is a better way. 171 | 172 | When you make a link to a page within your own directory or folder on your website, instead of putting in the whole URL, put in something more like this: 173 | 174 | ```html 175 | <a href="page2.html">Click here to go back to Page 2.</a> 176 | ``` 177 | 178 | Paste this line of code into page1.html. Watch the magic happen. 179 | 180 | Now, if you were to change your domain or location of your files, you don't have to change a thing. Boo yah. 181 | 182 | ### Other tags 183 | 184 | So, you can reference the links that I showed you before if you want to check out some jazzy stuff you can do with your page. There are some other ones though that you might want to see before we move on to cooler and bigger things. 185 | 186 | #### Images 187 | `<img>`. Let's just say you want to put an image on your website. This is probably a good tag to know. 188 | Add the following to page1.html: 189 | 190 | ```html 191 | <img src="https://i.imgur.com/B9q0A.gif" /> 192 | ``` 193 | 194 | Open up the page in a browser. WHOA. Image! So, the `<img>` tag is one of those special tags. First of all, it doesn't have a closing tag. You just stick in a `/` at the end of the one tag and you're done. Secondly, it also has a `src` attribute (which is short for *source*), and in the value of that attribute you put the URL of the image (similar to `href` in the anchor tag). 195 | 196 | One attribute that might be good for you to remember for `<img>` tags is the `alt` attribute. If you changed the code above to: 197 | 198 | ```html 199 | <img src="https://i.imgur.com/B9q0A.gif" alt="I could have danced all night" /> 200 | ``` 201 | 202 | When you load the page in the browser, the image looks the same. But, if you roll your mouse over the image, you'll see some words appear! WOW. That's the `alt` attribute. It stands for the *alternate text* for an image, and it's used when a user can't view the image for whatever reason (using a screen reader, slow connection, error in the `src` attribute, etc.). Or, in the case of [XKCD](http://xkcd.com/), it's used to add more humor to the page (roll your mouse over all of the comics on the site, they always add another joke or two that a lot of people don't know about). 203 | 204 | #### Line breaks 205 | Let's just say you want to keep all your content in one paragraph `<p>`, but you still want to break it up. 206 | 207 | That's easy. 208 | 209 | So, there's two special tags here, `<hr>` and `<br>`. They are *empty tags*, meaning they have no closing tag. 210 | 211 | `<hr>` stands for *horizontal rule*, and creates a visible line break. 212 | `<br>` is a simple line break, all it does is split your paragraph up. 213 | 214 | Try inserting these in between some of your `<p>` tags to try it out! 215 | 216 | #### Tables 217 | Tables are really cool. They can also be a bit confusing. Open up tables.html (in the **2 - Tags** folder) in a browser to check out the example table I made for you there. 218 | 219 | There's several tags for tables, but the essential ones are `<table>`, `<tr>`, `<th>`, and `<td>`. Look at tables.html in your editor. 220 | 221 | We're going to make our own table again on this page. You can delete the one I made for you, or just make one underneath the current one there. 222 | 223 | So, to create a table, you start with the `<table>` tag. Simple enough. 224 | 225 | This will contain all the parts of your table. Sometimes, tables have a `border` attribute that will equal some value for the thickness of the table's border (it's proper to have just "1" or nothing, for reasons we'll explain later). Go ahead and add one so it looks like this: 226 | 227 | ```html 228 | <table border="1"> 229 | </table> 230 | ``` 231 | 232 | Boom. Let's add some more. 233 | 234 | The next tag we're gonna check out is `<tr>`, which is for a *table row*. Easy peasy. So, let's add 3 `<tr>` tags to our table. 235 | 236 | ```html 237 | <table border="1"> 238 | <tr> 239 | </tr> 240 | <tr> 241 | </tr> 242 | <tr> 243 | </tr> 244 | </table> 245 | ``` 246 | 247 | And finally, we have the actual cells of the table. There are two types of tags for this, `<th>` (*table header*) and `<td>` (*table data*). As their names indicate, the former is for the header of the table and the latter is for all of the data in the table. 248 | 249 | In our first set of `<tr>` tags, add 4 `<th>` tags, and in the second and third `<tr>` tags add 4 `<td>` tags. 250 | 251 | ```html 252 | <table border="1"> 253 | <tr> 254 | <th></th> 255 | <th></th> 256 | <th></th> 257 | <th></th> 258 | </tr> 259 | <tr> 260 | <td></td> 261 | <td></td> 262 | <td></td> 263 | <td></td> 264 | </tr> 265 | <tr> 266 | <td></td> 267 | <td></td> 268 | <td></td> 269 | <td></td> 270 | </tr> 271 | </table> 272 | ``` 273 | 274 | Alright! Our table is all set up. We have a table with a `border=1` attribute, 3 rows, and 4 columns. Let's populate it with data so you can see a proper application of the `<table>` tag: 275 | 276 | ```html 277 | <table border="1"> 278 | <tr> 279 | <th>Item</th> 280 | <th>Quantity</th> 281 | <th>Rate</th> 282 | <th>Cost</th> 283 | </tr> 284 | <tr> 285 | <td>Candy</td> 286 | <td>10</td> 287 | <td>$.50</td> 288 | <td>$5.00</td> 289 | </tr> 290 | <tr> 291 | <td>Toothpaste</td> 292 | <td>2</td> 293 | <td>$3.00</td> 294 | <td>$6.00</td> 295 | </tr> 296 | </table> 297 | ``` 298 | 299 | Open the page in a browser and check out your work. Nice job! I'm truly impressed. Go eat something good and fattening. 300 | 301 | One other fun thing you can try playing with are the `colspan` and `rowspan` attributes. If you add `colspan="2"` (or `rowspan`, or any other number) into a `<th>` or `<td>` tag, the cell will expand past their cell size. For example, `<th colspan="2">` will give you a table header that spans 2 columns, and `<td rowspan="3">` will yield a cell that is the height of 3 rows. Jazzy! 302 | 303 | You can also nest tables, but I won't get into that right now. If you want to play around with the code, try adding some `<tr>` and `<td>` tags inside your current `<td>` tags. MaGiCal ThInGs. 304 | 305 | ### Making Things Gorgeous The Wrong Way 306 | 307 | So, your website right now looks pretty bland, and that's normal. But, we want a website that is hot, sexy, ravishing, and powerful. Yes, that's right, we want a website just like you. 308 | 309 | So first, I will show you the wrong way to style your pages. You might ask why, but trust me, if you learn in this order, you'll understand HTML attributes a lot better, and then when you move on to CSS your mind will explode with joy. Explode. 310 | 311 | #### Colors 312 | 313 | Alrighty. Let's get frisky. Open up the **3 - Styles** folder and the file style1.html. You might notice that this file is pretty bland right now, but that's what we're gonna fix. Be patient, my grasshopper. 314 | 315 | Add this line of code in the `<body>` somewhere below the header tags (I made a lot for fun...): `<p style="color: red">This text is hot like my body</p>` 316 | 317 | Oh man. Load that baby in a browser. WHAT. MAGNIFICENT. COLOR. 318 | 319 | The first thing we'll look at is the `style` attribute. You can style all kind of things in that, from colors to widths to heights to borders to weights. But for now, let's just talk color. 320 | 321 | So, you might wonder, "what the heck how does that work can I just type any color in that space where red is?" And the answer is no. You can type a ton of colors there, like `blue` and `yellow` and `cyan` and `magenta`, but you can't just say `oasisorange` or `electricwhite` and hope that that'll work. 322 | 323 | How do you get a specific color of your liking? Well that's when you use RGB or HEX colors. This is kind of a pain to grasp, it took me a little bit, so I'll explain it as simply as I can: RGB stands for Red, Green, and Blue. You can have the values 0 to 255 in each to form pretty much any color in existance. Whoa. The way to form an RGB code similarly to the one above is simple: `style="color: rgb(255,0,0)"`. In this example, there's 255 reds, 0 greens, and 0 blues. So, it's all red. Boom, simple enough. 324 | 325 | Now HEX colors is very similar. It consists of the hashtag sign `#`, and then 6 *hexadecimal digits*, which are 0123456789ABCDEF, with F being the highest digit. Like RGB, the first two digits of HEX are reds, the second two digits are blues, and the third couple of digits are greens. So, to write the same color code above, you'd do `style="color: #FF0000"` to get red, because you have FF for reds, 00 for blues, and 00 for greens. Simple? Simple. 326 | 327 | Don't worry, you won't have to come up with RGB and HEX colors yourself. There's plenty of websites and programs and color pickers out there to help you with that. Here's a few: 328 | 329 | * [Color Picker](http://www.colorpicker.com/) 330 | * [HTML color codes and names](http://www.computerhope.com/htmcolor.htm) 331 | * [HTML Color Codes](http://html-color-codes.info/) 332 | * [HTML Color Picker](http://www.w3schools.com/colors/colors_picker.asp) 333 | 334 | Try adding colors to various tags on the page! You can make your `<h1>` the color `#005DFC`, your `<h3>` tag `rgb(242,127,56)`, and your `<p>` tag `lightblue`. Keep playing til you're happy. 335 | 336 | Now, you might see the syntax in your HTML journey where you actually have the `color` attribute, like `<p color="red">wut</p>`. Though this is technically allowed, please don't do this. Please. You'll be so much happier in the long run, I promise. 337 | 338 | #### Width and Height 339 | 340 | So, what if you want to make a picture or a paragraph a different size? Easy peasy. 341 | 342 | There are two options you can use, the `style` attribute and the `width` and `height` attributes. I'll show you both. 343 | 344 | Take this block of code here and stick it into style1.html: 345 | 346 | ```html 347 | <img src="https://i.imgur.com/4ihC2Yb.gif" /> 348 | ``` 349 | 350 | Now, let's just say you want the image to be an exact size, say, 600x800. All you need to do is add `width` and `height` attributes to do just that! 351 | 352 | ```html 353 | <img src="https://i.imgur.com/4ihC2Yb.gif" width="600" height="800" /> 354 | ``` 355 | 356 | Load that baby in a browser. Boo yah. But, you'll notice that the proportions of the image are a little off. What a pain. That's actually pretty easy to fix. Let's say that you absolutely have to have the width at 600 pixels, but the height can slide. It's as easy as taking out the `height` attribute. 357 | 358 | ```html 359 | <img src="https://i.imgur.com/4ihC2Yb.gif" width="600" /> 360 | ``` 361 | 362 | Refresh dat page. Huzzah. Same works for if you have a set height that you want, just include the `height` attribute and not the `width`. 363 | 364 | Now, you can also do these changes with the `style` attribute. 365 | 366 | ```html 367 | <img src="https://i.imgur.com/4ihC2Yb.gif" style="width: 600px" /> 368 | ``` 369 | 370 | Simple enough! Now, we've looked at the `style` attribute a bit now but I haven't explained the syntax. The `style` attribute is for *inline styles*. This means that you're styling your HTML directly in each element, rather than using CSS. But, we haven't gotten that far yet, so I won't go into that part. 371 | 372 | Now, the syntax within a `style` attribute is a little funky. It is always `style="property: value"`, where the *property* is literally a property of the tag you're editing (for example, `color`, `width`, `height`), and the *value* is to what you're changing or editing the property (for example `blue`, `600px`, `#FF0000`). 373 | If you have more than one property that you want to style, for example both height and width, you put a semicolon between delarations. So, in our example, if you want to edit both height and width of our image in the `style` attribute, we'd do: 374 | 375 | ```html 376 | <img src="https://i.imgur.com/4ihC2Yb.gif" style="width: 600px; height: 800px" /> 377 | ``` 378 | 379 | Why is the syntax this funky? Well, that's because it's secretly CSS syntax. But we'll get into that more later. 380 | 381 | #### Borders 382 | 383 | What if we have a paragraph IN A BOX. That's right. Kind of like a table. But not. That'd be cool. Of course, there are plenty of other things that can have a border. Buttons (we'll get to those later), color blocks (also later), and images, and MORE can have them. Mmmhm. 384 | 385 | Let's take the same image we played with before: 386 | 387 | ```html 388 | <img src="https://i.imgur.com/4ihC2Yb.gif" /> 389 | ``` 390 | 391 | Now, you can add `border="5"` to this and you'll get a border with a thickness of 5 pixels around the image. But, this attribute is actually no longer supported for things other than tables (oh yeah, we used this for tables. Memories.), so we can do this a better way. You guessed it. `style` is coming to SAVE THE DAY. 392 | 393 | The styling for borders with the `style` attribute is a bit different than just adding `border="5"`, but it's also much more powerful. Let's change our code: 394 | 395 | ```html 396 | <img src="https://i.imgur.com/4ihC2Yb.gif" style="border:5px solid black" /> 397 | ``` 398 | 399 | Whoa. That's a lot of crap in there. Let's break it down. 400 | 401 | The first part of the declaration is obvious, `border`. This is the property that we're editing. Man, this is easy. 402 | 403 | Next, we have 3 parts in the value section. The first part is `5px`. Firstly, `px` stands for *pixels*. We used this above for our width and heights as well. You always have to include the units (just like in 5th grade math) in your styling, and our units here are pixels. Now, that whole first part, `5px`, is the border's thickness. You guessed it: it's 5 pixels thick. Gosh you're smart. 404 | The next part is the *border style*. You can plug in several words here, as indicated [on this webpage](http://www.w3schools.com/css/css_border.asp). We used `solid`, but you can also say `dotted`, `dashed`, or `double`. There are some other words you can use, but those depend on the color of the border. 405 | Color? What? OH YEAH. That's the third part of the border style. You can stick in any color for that, but in this example, we have `black`. 406 | 407 | Let's mix it up a bit with different borders for you to check out. I'm just going to keep using the same image, you can replace it with whatever. Stick this in the `<body>` tags of style1.html and check it out, and play with the values yourself! 408 | 409 | ```html 410 | <img src="https://i.imgur.com/4ihC2Yb.gif" style="border:5px dotted #ffcc00" /> 411 | <img src="https://i.imgur.com/4ihC2Yb.gif" style="border:10px ridge rgb(77, 145, 99); width: 300px" /> 412 | <img src="https://i.imgur.com/4ihC2Yb.gif" style="border:8px outset red" /> 413 | <img src="https://i.imgur.com/4ihC2Yb.gif" style="border:3px double #333a21; height: 30px" /> 414 | ``` 415 | 416 | Notice how I added `width` and `height` to a couple of them. We're getting incestuous with our stylings. Aww yeah. 417 | 418 | #### Text Styles 419 | 420 | Besides having header tags and colors, there are other text styles that you can use. What if you want bold text, or italics? Different sizes? Once again, the `style` attribute comes to the rescue. 421 | 422 | Add the following to style1.html in **3 - Styles**: 423 | 424 | ```html 425 | <p style="text-align: center; font-weight: bold">This text is magnificent.</p> 426 | ``` 427 | 428 | Load that in a browser and check it out. YUS. You've got some magically centered, bolded text! The properties defined here are pretty simple to follow. `text-align` lets you align your text either `center`, `left`, or `right`. Mess around with that so you get it. 429 | `font-weight`, you guessed it, edits the weight in your text. It can have the values `normal` for normally weighted text, `bold` for thick characters, `bolder` for thicker characters (specific, right?), `lighter` for lighter-weighted characters, and the numbers `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, and `900` (where 400 is the same as normal and 700 is the same as bold). 430 | 431 | Play with this one now: 432 | 433 | ```html 434 | <p style="font-family: Arial; font-style: italic">This text is magnificent.</p> 435 | ``` 436 | 437 | Browser time. You've now got some text in the font Arial, and it's italic! WOOO HOOOOOO. 438 | The properties we used here are `font-family` and `font-style`. For the former, you can choose a lot of fonts, but you have to be careful. Not every computer has the same fonts. This is just my personal opinion: don't put something here besides Arial unless you've done some JavaScript magic. And because I'm assuming you don't know JavaScript, don't use this unless you're changing this to Arial. At least not yet. :) 439 | And for `font-style`, it can be `normal`, `oblique`, and `italic`. You can play with those now, it's pretty straightforward. 440 | 441 | ### The `<head>` Tag 442 | 443 | Before we start going insane with how good you are at HTML, let's start looking at something that you haven't played with yet. The `<head>` tag. 444 | 445 | I mentioned before that in the `<head>` is information that the user doesn't see, so it's not that big of a deal, right? WRONG. It's not all about looks. That's at least what I try to tell people when they see me. 446 | 447 | So. What else can go in the `<head>`? We've already got `<title>`, which we've talked about already to help search engines find us. What if we want to help the search engines out a bit more? Incoming, the `<meta>` tag. 448 | 449 | The `<meta>` tag gives *metadata* about the HTML document. Metadata will not be displayed on the page, but machines can read it. An example of metadata not on a webpage is in a typical music file. When you have a music file on your computer and you open it in some media player of some kind, it shows the album title, the artist, the genre, and other information about the song. This information is metadata. The user can't see it directly in the music file, but your music players can read it and will tell you what it is. 450 | So, on a website, this metadata is used by search engines, your browser, and other web services to make your website easy to find, read, and display. 451 | 452 | There are 3 important uses for the `<meta>` tag. There are plenty of other uses, but let's be honest, I don't care about them right now, and I don't think you do either. 453 | Open up the **4 - Head** (heh get it? Forehead? I crack myself up.) folder, and open cooking.html in your favorite editor. 454 | 455 | * *Defining a description of your site.* Again, this one is for the search engines. Whenever you search for a website, there's a tiny description in the search results. Go search for anything right now, and you'll see it. So, you can define what that is with this snippet: 456 | 457 | ```html 458 | <meta name="description" content="The best cooking website in the entire universe. You're welcome."> 459 | ``` 460 | 461 | Add this right after the keywords line in cooking.html. Now if people were searching for this, they'd get this description and instantly see that your website is the best cooking website in the universe. 462 | 463 | * *Defining the author of a website.* Let's say that someone's looking for the author of your website, because your writing style is sexy. Or something. You can let them know who you are with the following: 464 | 465 | ```html 466 | <meta name="author" content="Sexy McGoodlooking"> 467 | ``` 468 | 469 | Add this after your description line, and stick your name in it! I think I got it as close as possible. 470 | 471 | * *Refreshing your document every 30 seconds.* This one is for your browser. Let's say that you have comments available on your recipes, and you want to have the page refresh so the comments can appear "live". Just add this: 472 | 473 | ```html 474 | <meta http-equiv="refresh" content="30"> 475 | ``` 476 | 477 | And there you have it, a self-refreshing webpage. You're so good at this. 478 | 479 | ### Putting it all together so far 480 | 481 | Okay, you have a pretty solid understanding of stuff so far. I want you to take cooking.html, and make it shine. 482 | Resize the images so the page is more uniform. Add borders to them. Change the font styles and weights. Change the colors. Add some keywords in the metadata and change the title of the page. 483 | Using the information I've given you so far, you can make a pretty good looking site! 484 | 485 | ## CSS is magical, and now you're gonna learn it. 486 | 487 | So far, we've been making things pretty the wrong way. So, we're going to learn it the right way. So excited. 488 | 489 | Right now, I'm going to show you how to write CSS just straight in your HTML documents. That's still kind of wrong, but it'll give you the basics. After that, we'll move into the big leagues and have separate files for everything. Pumped. 490 | 491 | Open up your **3 - Styles** folder again and open style2.html in your favorite editor. This site is pretty barebones. Let's take out the barebones part and just make it pretty. 492 | 493 | We're going to be working in the `<head>` tag again. Underneath the `<title>` tag, stick in the following: 494 | 495 | ```html 496 | <style> 497 | body { } 498 | 499 | h1 { } 500 | 501 | p { } 502 | 503 | ol { } 504 | </style> 505 | ``` 506 | 507 | Congratulations. You have some empty CSS. Now, what the heck is CSS anyway? Well, CSS stands for *Cascading Style Sheets*. Gee whiz, that word *style* is everywhere. And it's true. The `style` attribute is for styling *inline* HTML (just that line of code), the `<style>` tag is for holding CSS, and CSS *defines* the styles! Let that sink in. Nice. Stylish. Just like you. 508 | 509 | Now, you'll notice some familiar keywords in there, in particular, `body`, `h1`, `p`, and `ol`. That's right, they're the tags we know and love! But, in CSS, these are called *selectors*. The selector tells us what tag you're about to style. So, whatever code you put in between the curly braces `{}` after the `body` selector will affect everything in the `<body>` tags. Whatever you put in the braces after the `p` selector will affect what's in the `<p>` tags. 510 | Whatever code you have in those curly braces will only affect that tag, so if you try editing the font colors for the `h1` selector, it won't affect whatever is in the `p` selector's tags. Each portion of code `selector { code }` in CSS is called a *declaration*. Make sense? Good. If not, keep reading and hopefully it will become more clear as we go on. 511 | 512 | The code that we're going to be putting in each declaration is the same syntax as the code that we normally put in the `style` attribute. How convenient. So, change your code above to the following: 513 | 514 | ```html 515 | <style> 516 | body { 517 | font-family: Arial; 518 | } 519 | 520 | h1 { 521 | color: red; 522 | text-align: center; 523 | } 524 | 525 | p { 526 | font-weight: bolder; 527 | } 528 | 529 | img { 530 | width: 400px; 531 | border: 5px solid #333333; 532 | } 533 | 534 | ol { 535 | color: #333333; 536 | } 537 | </style> 538 | ``` 539 | 540 | Recognize that? It's exactly the same! For each selector, there is a *property* of that selector, and each property has a *value*, just like how we wrote it in the `style` attributes! 541 | 542 | You will always have your CSS in the syntax, `selector { property: value; property: value; }`. I've only shown you some properties so far, but don't worry. There are plenty more to come. 543 | 544 | Try playing around with the CSS we have right now. Edit the colors, add some borders, change the font styles. Don't forget your semicolons! 545 | 546 | ### Classes and IDs and other Segregation 547 | 548 | So, you have some of the CSS basics down already. You're so smart. It's really a simple language, once you know the basic syntax. So, now we'll get into more fancy stuff. What if you want to edit several tags differently? 549 | 550 | #### Classes 551 | 552 | Let's say that we have 8 `<p>` tags on our HTML page (hint: open style3.html in the **3 - Styles** folder). 553 | If we want to style each of these tags differently, we can use *classes*. A class is actually an HTML attribute that you can name whatever you want. 554 | Check out style3.html to see the classes I added to the `<p>` tags on the page. When you add a class, the user doesn't see it. 555 | But, you can style specific classes to do what you want, instead of having all `<p>` tags be the same. 556 | 557 | How about we style one of the classes specifically? It's simple. Just take the class name you made up (I'll use the `poemtitle` class for my example) and add a period `.` in front of it to select it in CSS, like so: 558 | 559 | ```css 560 | .poemtitle { 561 | 562 | } 563 | ``` 564 | 565 | And there you have it! Even though you might have different styles for your paragraphs, you can style the ones of class `poemtitle` individually. 566 | For this example, let's make all paragraphs with the font family Arial, the `poemtitle`s font weight `bolder`, the `author`s the color `#555555`, and the `poem`s in `italic`. 567 | Try doing it on your own if you can (just put your code in the given `<style>` tags), but you're welcome to cheat: 568 | 569 | ```css 570 | p { 571 | font-family: Arial; 572 | } 573 | .poemtitle { 574 | font-weight: bolder; 575 | } 576 | .author { 577 | color: #555555; 578 | } 579 | .poem { 580 | font-style: italic; 581 | } 582 | ``` 583 | 584 | Gosh you're good at this. Go eat a cookie. 585 | 586 | [Pausing here for cookie break] 587 | 588 | #### IDs 589 | 590 | Now, let's talk about IDs. They are very similar to classes. The only real difference between classes and IDs is that you can only have one of each ID. So, for example, if you have a special paragraph that you only want to style once, then you can stick in there the `id` attribute like so: 591 | 592 | ```html 593 | <p id="special">This is so special that I want it uniquely styled forever.</p> 594 | ``` 595 | 596 | When you want to style your IDs, you put a hashtag `#` before it in your CSS, like so: 597 | 598 | ```css 599 | #special { 600 | 601 | } 602 | ``` 603 | 604 | Remember: You can only use an ID once. IDs are more helpful when you're controlling the element with JavaScript, not styling, but that's something for another day. 605 | 606 | #### Other Segregation 607 | 608 | Let's say that you want to separate individual text in your paragraphs or sections on your page. Let's introduce 2 new tags: `<span>` and `<div>`. 609 | 610 | ##### The `<span>` tag 611 | The `<span>` tag is pretty invisible unless you style it. It's used to group *inline-elements* (so like a word in a paragraph), and it doesn't actually do anything unless you style or manipulate it with something else. 612 | 613 | So, let's say you have a paragraph and you really want to emphasize some text within a paragraph without a line break or anything. In comes `<span>`. For example: 614 | 615 | ```html 616 | <p>"My grandmother started walking <span>five miles a day</span> when she was sixty. She's ninety-seven now, and <span>we don't know where the heck she is.</span>" </p> 617 | <p>~ Ellen DeGeneres </p> 618 | ``` 619 | 620 | In the above quote, you might want to style the `<span>` tags differently than the rest of the paragraph. Maybe you want those words bold, or italics, or in red. Now you can. 621 | 622 | Add some `<span>` tags around your favorite lines of the poems in style3.html of the **3 - Styles** folder. Then, put the following CSS in your `<style>` tags: 623 | 624 | ```css 625 | p span { 626 | font-style: italic; 627 | } 628 | ``` 629 | 630 | Wait a minute. Hold up. `p span`?? WHY THE SPACE? Calm yourself, I'll tell you. This is called *nesting* CSS. When you have a space in your selector like this, it means that, in this case, the style will only affect `<span>` tags within `<p>` tags. So, if you put `<span>` tags around a word in your `<h1>` tags, your CSS will not affect it. You can still have a plain `span` selector, or nest it in one of your classes too: 631 | 632 | ```css 633 | span { 634 | font-weight: bold; 635 | } 636 | .author span { 637 | color: #999999; 638 | } 639 | ``` 640 | 641 | Make sense? I hope so. To sum up: `<span>` tags separate specific parts of paragraphs or other inline sections of a page. They do nothing otherwise. You can nest CSS if you want. Boom. Next. 642 | 643 | ##### The `<div>` tag 644 | 645 | Alrighty. Go enjoy a beach vacation and then come back to this. 646 | 647 | Welcome back. 648 | 649 | The `<div>` tag is very similar to the `<span>` tag, in that it separates a section of something but doesn't do much else. However, the difference with `<div>` tags is that they are *block level* elements, not just within a line of text. 650 | 651 | The `<div>` tag might end up being the tag that you use most often. It is what lets you easily make website layouts (with help from CSS of course), and so, let's play with it! 652 | 653 | Open up the **5 - Layout** folder, and use your editor to open `homepage.html`. 654 | 655 | ```html 656 | <!doctype html> 657 | <html> 658 | <head> 659 | <title> My Website 660 | 663 | 664 | 665 |
666 | 667 |
668 | 669 | 670 | 671 | ``` 672 | 673 | Besides the `
` tags, everything here should look familiar. Each of the `` have a `class`, which means we should style those, right? Right. 674 | 675 | Within those `