You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-46Lines changed: 46 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,30 @@
1
1
HTML+CSS Tutorial
2
2
=================
3
3
4
-
###Who
4
+
###Who
5
5
6
6
I'm Cassidy. I'm software engineer & developer evangelist at [Clarifai](http://clarifai.com), and I've been teaching myself HTML, CSS, and other web programming and scripting for over 10 years.
7
7
And I want to teach you now.
8
8
Because you're good looking.
9
9
And because it's useful.
10
10
11
-
###What
11
+
###What
12
12
13
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
14
15
-
###When
15
+
###When
16
16
17
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
18
19
-
###Where
19
+
###Where
20
20
21
21
On a computer. Here.
22
22
23
-
###Why
23
+
###Why
24
24
25
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.
So the first thing you'll need is an editor to edit your jazz. There's tons of options out there.
73
73
@@ -79,7 +79,7 @@ So the first thing you'll need is an editor to edit your jazz. There's tons of
79
79
80
80
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!
81
81
82
-
###HTML Tag Structure
82
+
###HTML Tag Structure
83
83
84
84
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.
85
85
@@ -118,7 +118,7 @@ Inside `<html>`, there are two elements: `<head>`and `<body>`. Contained in `<he
118
118
119
119
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!
120
120
121
-
###Structuring text
121
+
###Structuring text
122
122
123
123
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?
124
124
@@ -132,7 +132,7 @@ Next, we have `<p>` tags. `<p>` adds a *paragraph* of text to our website, whic
132
132
133
133
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>`!
134
134
135
-
###Links
135
+
###Links
136
136
137
137
Links are what makes the world/Internet go 'round. Seriously. So, let's learn about them.
138
138
@@ -155,7 +155,7 @@ So, anyway, the attribute 'href' tells us where the link is going to go when the
155
155
156
156
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!
157
157
158
-
####Adding links to other pages in your website
158
+
####Adding links to other pages in your website
159
159
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.
160
160
161
161
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>`.
@@ -170,11 +170,11 @@ Paste this line of code into page1.html. Watch the magic happen.
170
170
171
171
Now, if you were to change your domain or location of your files, you don't have to change a thing. Boo yah.
172
172
173
-
###Other tags
173
+
###Other tags
174
174
175
175
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.
176
176
177
-
####Images
177
+
####Images
178
178
`<img>`. Let's just say you want to put an image on your website. This is probably a good tag to know.
179
179
Add the following to page1.html:
180
180
@@ -188,7 +188,7 @@ One attribute that might be good for you to remember for `<img>` tags is the `al
188
188
189
189
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).
190
190
191
-
####Line breaks
191
+
####Line breaks
192
192
Let's just say you want to keep all your content in one paragraph `<p>`, but you still want to break it up.
193
193
194
194
That's easy.
@@ -200,7 +200,7 @@ So, there's two special tags here, `<hr>` and `<br>`. They are *empty tags*, me
200
200
201
201
Try inserting these in between some of your `<p>` tags to try it out!
202
202
203
-
####Tables
203
+
####Tables
204
204
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.
205
205
206
206
There's several tags for tables, but the essential ones are `<table>`, `<tr>`, `<th>`, and `<td>`. Look at tables.html in your editor.
@@ -281,13 +281,13 @@ One other fun thing you can try playing with are the `colspan` and `rowspan` att
281
281
282
282
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.
283
283
284
-
###Making Things Gorgeous The Wrong Way
284
+
###Making Things Gorgeous The Wrong Way
285
285
286
286
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.
287
287
288
288
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.
289
289
290
-
####Colors
290
+
####Colors
291
291
292
292
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.
293
293
@@ -314,7 +314,7 @@ Try adding colors to various tags on the page! You can make your `<h1>` the col
314
314
315
315
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.
316
316
317
-
####Width and Height
317
+
####Width and Height
318
318
319
319
So, what if you want to make a picture or a paragraph a different size? Easy peasy.
320
320
@@ -347,7 +347,7 @@ If you have more than one property that you want to style, for example both heig
347
347
348
348
Why is the syntax this funky? Well, that's because it's secretly CSS syntax. But we'll get into that more later.
349
349
350
-
####Borders
350
+
####Borders
351
351
352
352
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.
353
353
@@ -379,7 +379,7 @@ Let's mix it up a bit with different borders for you to check out. I'm just goi
379
379
380
380
Notice how I added `width` and `height` to a couple of them. We're getting incestuous with our stylings. Aww yeah.
381
381
382
-
####Text Styles
382
+
####Text Styles
383
383
384
384
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.
385
385
@@ -398,7 +398,7 @@ Browser time. You've now got some text in the font Arial, and it's italic! WOO
398
398
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. :)
399
399
And for `font-style`, it can be `normal`, `oblique`, and `italic`. You can play with those now, it's pretty straightforward.
400
400
401
-
###The `<head>` Tag
401
+
###The `<head>` Tag
402
402
403
403
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.
404
404
@@ -436,13 +436,13 @@ Add this after your description line, and stick your name in it! I think I got
436
436
437
437
And there you have it, a self-refreshing webpage. You're so good at this.
438
438
439
-
###Putting it all together so far
439
+
###Putting it all together so far
440
440
441
441
Okay, you have a pretty solid understanding of stuff so far. I want you to take cooking.html, and make it shine.
442
442
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.
443
443
Using the information I've given you so far, you can make a pretty good looking site!
444
444
445
-
##CSS is magical, and now you're gonna learn it.
445
+
##CSS is magical, and now you're gonna learn it.
446
446
447
447
So far, we've been making things pretty the wrong way. So, we're going to learn it the right way. So excited.
448
448
@@ -508,11 +508,11 @@ You will always have your CSS in the syntax, `selector { property: value; proper
508
508
509
509
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!
510
510
511
-
###Classes and IDs and other Segregation
511
+
###Classes and IDs and other Segregation
512
512
513
513
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?
514
514
515
-
####Classes
515
+
####Classes
516
516
517
517
Let's say that we have 8 `<p>` tags on our HTML page (hint: open style3.html in the **3 - Styles** folder).
518
518
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.
@@ -551,7 +551,7 @@ Gosh you're good at this. Go eat a cookie.
551
551
552
552
[Pausing here for cookie break]
553
553
554
-
####IDs
554
+
####IDs
555
555
556
556
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:
557
557
@@ -566,11 +566,11 @@ When you want to style your IDs, you put a hashtag `#` before it in your CSS, li
566
566
567
567
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.
568
568
569
-
####Other Segregation
569
+
####Other Segregation
570
570
571
571
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>`.
572
572
573
-
#####The `<span>` tag
573
+
#####The `<span>` tag
574
574
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.
575
575
576
576
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:
@@ -600,7 +600,7 @@ Wait a minute. Hold up. `p span`?? WHY THE SPACE? Calm yourself, I'll tell y
600
600
601
601
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.
602
602
603
-
#####The `<div>` tag
603
+
#####The `<div>` tag
604
604
605
605
Alrighty. Go enjoy a beach vacation and then come back to this.
606
606
@@ -700,7 +700,7 @@ Makes sense? I hope so. You're hot.
700
700
701
701
Okay, so if you open `homepage.html` in the browser, you see nothing. That's okay. Let's change that by learning a few new CSS properties!
702
702
703
-
######Background color
703
+
######Background color
704
704
705
705
One property that you will learn to know and love is `background-color`.
706
706
It does exactly what you would expect it to: it sets the background color of the element it is styling!
@@ -742,7 +742,7 @@ Let's add some backgrounds.
742
742
Save in your editor and now refresh in that browser! WOW. COLOR. Now, our site definitely isn't perfect yet.
743
743
Let's throw some MORE new CSS properties at you!
744
744
745
-
######Floating
745
+
######Floating
746
746
747
747
One property that you will probably use fairly often is `float`. This is one of those properties that you will learn to both love and hate.
748
748
It's kind of magical.
@@ -810,7 +810,7 @@ Let's make it so that your header and footer are always on the top and bottom of
810
810
811
811
Incoming, the `position` property.
812
812
813
-
######Positioning
813
+
######Positioning
814
814
815
815
The `position` property is pretty much exactly what one would expect a positioning property to do: It positions things.
816
816
@@ -873,7 +873,7 @@ Why the heck is that happening?
873
873
874
874
I'll tell you.
875
875
876
-
######Margins and Padding
876
+
######Margins and Padding
877
877
878
878

879
879
@@ -1012,7 +1012,7 @@ The same goes for `padding`, you can also do `padding: 5px 10px 15px 0px;`, etc.
1012
1012
Now, with all that you've learned so far, you should probably make this a really great, functional website.
1013
1013
I'll teach you just one more thing, and then I'll set you free like a bird or something.
1014
1014
1015
-
######Z-Index
1015
+
######Z-Index
1016
1016
1017
1017
The property `z-index` isn't one that you'll run into super often, but it's something that will help you in the long run.
1018
1018
@@ -1098,12 +1098,12 @@ But hey, that's a LOT of reusing code. Plus what if someone is trying to read y
1098
1098
1099
1099
Duh.
1100
1100
1101
-
###The `<link>` Tag, Comments, and other Developer Joys
1101
+
###The `<link>` Tag, Comments, and other Developer Joys
1102
1102
1103
1103
Let's just say you want to reuse your styles across your website on every page. It makes sense.
1104
1104
It'd be kind of annoying to have drastic changes on every page.
1105
1105
1106
-
####The `<link>` tag
1106
+
####The `<link>` tag
1107
1107
1108
1108
That's where the `<link>` tag comes in! The `<link>` tag is an empty tag (like <br> and <img>), so it has no end tag, and it's used to link to external stylesheets!
1109
1109
@@ -1122,15 +1122,15 @@ And finally, `href`. You remember this one, I hope! It's just like our `<a>` t
1122
1122
Let's check out this `<link>` tag in action. Open up the **6 - Linking** folder and open home.html, and paste the `<link>` line above on the line below the `<title>` tags in the `<head>`. Voila! That's it. Refresh your browser and check out the magic. It should look just like what we made in the previous section!
1123
1123
Now, if you open the main.css file in your editor, you'll see that it's all the CSS you recognize and love, but there's no `<style>` tags. Those tags aren't needed when you are using a CSS file!
1124
1124
1125
-
####Commenting
1125
+
####Commenting
1126
1126
1127
1127
Let's just say that you want to show off your code to someone, but they're not exactly sure what you're doing.
1128
1128
1129
1129
You can add comments!
1130
1130
1131
1131
*Comments* in your code are blocks of text that will not be read by the computer. Every computer language has them.
1132
1132
1133
-
#####HTML Comments
1133
+
#####HTML Comments
1134
1134
1135
1135
In HTML, a comment looks like this:
1136
1136
@@ -1140,7 +1140,7 @@ As you can see, it almost looks like a regular tag, with an opening `<!--` and a
1140
1140
1141
1141
Look inside the **7 - Project** folder, and open index.html. You'll see a few comments there. Notice how you can put them all on one line, or in a multi-line block! As long as you have a beginning `<!--` and end `-->`, you have total freedom with comments.
1142
1142
1143
-
#####CSS Comments
1143
+
#####CSS Comments
1144
1144
1145
1145
Don't worry, you can comment your CSS too!
1146
1146
@@ -1155,12 +1155,12 @@ And again, you can have single-line comments, and multi-line ones too.
1155
1155
Comments are great for keeping track of what you're doing, especially if a project you're working on spans over a period of time.
1156
1156
You can make notes for yourself to check later, or you could just tell someone who is reading your code that they are attractive.
1157
1157
1158
-
####Other Developer Joys
1158
+
####Other Developer Joys
1159
1159
1160
1160
There's so many things that could go in this section for such a generic title. So, what am I going to tell you?
1161
1161
Well, I'm going to tell you what I *haven't* taught you so far.
1162
1162
1163
-
#####Forms
1163
+
#####Forms
1164
1164
1165
1165
A common thing you'll see on websites are forms, like textboxes, buttons, and checkboxes.
1166
1166
I didn't teach you these because you can't do things with them unless you know a bit more than beginner knowledge, which isn't the purpose of this tutorial.
@@ -1172,7 +1172,7 @@ If you're really dying to see a button, here you go:
1172
1172
And there you have it, a button on your website! If you actually want to know how to make the button or form do something, you'll need to know some JavaScript.
1173
1173
Until you do, here's more information on buttons: [W3Schools - HTML Forms](http://www.w3schools.com/tags/tag_form.asp)
1174
1174
1175
-
#####HTML5 and CSS3
1175
+
#####HTML5 and CSS3
1176
1176
1177
1177
If you've read anything about the internet and developing for it, you've probably heard some key words thrown around, and a couple of those key words are HTML5 and CSS3.
1178
1178
What are those, actually? Well, HTML5 is the latest standard for HTML. The previous HTML version came out in 1999, which is quite a while ago. Unless you're time traveling right now and you printed this out to read as you go.
@@ -1189,13 +1189,13 @@ If you want to read more about HTML5 and CSS3, check out some of the links below
1189
1189
*[HTML5 Rocks](http://www.html5rocks.com/)
1190
1190
*[Dive Into HTML5](http://diveintohtml5.info/)
1191
1191
1192
-
#####How To Meet Ladies/Laddies (Get it? HTML Jokes are the best...)
1192
+
#####How To Meet Ladies/Laddies (Get it? HTML Jokes are the best...)
1193
1193
1194
1194
Honestly I have nothing to put here I just like the joke that HTML stands for that.
1195
1195
1196
1196
I hope your HTML is spick and `<span>`. Heh.
1197
1197
1198
-
##Final Project!
1198
+
##Final Project!
1199
1199
1200
1200
Alrighty! So you've looked at the **7 - Project** folder a bit, but I haven't told you what that folder is for yet.
1201
1201
@@ -1219,7 +1219,7 @@ The best way to learn is by doing. Do as much as you can until you think you ha
1219
1219
1220
1220
And if you need help you can always come back and visit. :)
0 commit comments