├── readme.md ├── html-css.md ├── databases.md ├── ux.md └── php.md /readme.md: -------------------------------------------------------------------------------- 1 | # Training notes 2 | 3 | A few notes prepared while writing training courses... 4 | 5 | - [HTML & CSS](html-css.md) 6 | - [JavaScript](javascript.md) 7 | - [Databases](databases.md) 8 | - [PHP](php.md) 9 | - [UX](ux.md) 10 | -------------------------------------------------------------------------------- /html-css.md: -------------------------------------------------------------------------------- 1 | # HTML & CSS notes 2 | 3 | A few notes prepared while writing training courses... 4 | 5 | 6 | ## The World-wide web 7 | 8 | The internet (as a collection of networked computers) existed for decades before the creation of the world-wide web 9 | 10 | The methods of communication between these computers wasn't as simple (for the average person) as it is today 11 | 12 | In 1990, Tim Berners-Lee, a British engineer working at CERN (European Organisation for Nuclear Research, in Switzerland) combined several key communication protocols known collectively as the 'World-Wide Web' 13 | 14 | > "A web of hypertext documents to be viewed by browsers using a client–server architecture" 15 | 16 | 17 | ### Components of the World-Wide Web 18 | 19 | The key components of the 'World-Wide Web' 20 | 21 | - HTML - a markup language used to give structure to information 22 | - URLs - used to uniquely identify documents 23 | - Hyperlinks (hypertext) - to move between documents 24 | - Web browsers - a simple Graphical User Interface (GUI) to view these documents 25 | - Web servers - a way to provide requested documents 26 | 27 | These technologies have revolutionised our consumption of information 28 | 29 | 30 | ### The World-Wide Web Consortium (W3C) 31 | 32 | An organisation set up by Tim Berners-Lee in 1994 33 | 34 | They are responsible for developing "non-proprietary, interoperable technologies" for the World Wide Web 35 | 36 | They attempt to make the web universally accessible, regardless of ability, language, or culture 37 | 38 | They do this by creating standards for web technologies, such as HTML, CSS and XML 39 | 40 | 41 | ### Web browsers 42 | 43 | Many different options 44 | 45 | These days, they're all fairly similar, and compete on adding new features 46 | 47 | Most browsers update themselves, quite often 48 | 49 | It wasn't always this way - *Internet Explorer 6...* 50 | 51 | 52 | ### Browser technologies 53 | 54 | 3 main languages: 55 | 56 | - Content - HTML 57 | - Styling - CSS 58 | - Interaction - JavaScript 59 | 60 | 61 | ### Why you should learn to write code by hand 62 | 63 | - Gain complete control over your site 64 | - Stop your site being a 'black box' that just works 65 | - With a bit of practice, it's the quickest way to make things 66 | - It's easier to debug if something isn't working 67 | - Easy to make quick fixes from anywhere 68 | 69 | 70 | ## HTML 71 | 72 | Describes the structure of content - used to give structure to information 73 | 74 | It is a universal language - provided you have a web browser that is capable of reading HTML, you can use any operating system or device to view it 75 | 76 | 77 | ### Giving structure with code 78 | 79 | We "mark up" a document to give it structure, by describing the meaning of its parts 80 | 81 | HTML is a type of "markup" language 82 | 83 | 84 | ### How would we mark up a book? 85 | 86 | Take the following example of a book: 87 | 88 | > "The Pineapple: King of Fruits" by Francesca Beauman. Published by Chatto & Windus in 2005. 89 | 90 | Or 91 | 92 | > In 2005, Francesca Beauman wrote "The Pineapple: King of Fruits" and published with Chatto & Windus. 93 | 94 | Humans can understand this informtion, but to a computer it needs putting into a formal structure: 95 | 96 | - *Title*: The Pineapple: King of Fruits 97 | - *Author*: Francesca Beauman 98 | - *Date*: 2005 99 | - *Publisher*: Chatto & Windus 100 | - *Description*: This enchanting, juicy history… 101 | 102 | 103 | In a mock markup language, this becomes: 104 | 105 | ``` 106 | 107 | Pineapple: King of the fruits 108 | Francesca Beauman 109 | 2005 110 | Chatto & Windus 111 | This enchanting, juicy history… 112 | 113 | ``` 114 | 115 | ### Hyper-Text Markup Language (HTML) 116 | 117 | HTML is a collection of simple `` 118 | 119 | You only need to know a few to get started: 120 | 121 | - `

`Headings`

` (there are 6 heading levels, from `

` to `

`) 122 | - `

`Paragraphs`

` 123 | - ``Emphasis`` 124 | - ``Strong importance`` 125 | - Images: `My cat` 126 | - `Links` 127 | 128 | 129 | ### HTML rules 130 | 131 | There are a few simple rules: 132 | 133 | 134 | #### Opening & closing tags 135 | 136 | Tags wrap around the content they describe: 137 | 138 | ``` 139 | content 140 | ``` 141 | 142 | ***WRONG*** 143 | 144 | ``` 145 |

In Xanadu did Kubla Khan 146 |

A stately pleasure-dome decree 147 | ``` 148 | 149 | ***WRONG*** 150 | 151 | ``` 152 |

In Xanadu did Kubla Khan 153 | ``` 154 | 155 | ***RIGHT*** 156 | 157 | ``` 158 |

In Xanadu did Kubla Khan

159 | ``` 160 | 161 | Some tags are 'self-closing', because they don't wrap around content: 162 | 163 | ``` 164 | Image description 165 | ``` 166 | 167 | 168 | #### Nesting tags 169 | 170 | Tags should be properly nested 171 | 172 | ***WRONG*** 173 | 174 | ``` 175 |

In Xanadu did Kubla Khan

176 | ``` 177 | 178 | ***WRONG*** 179 | 180 | ``` 181 |

In Xanadu

did Kubla Khan 182 | ``` 183 | 184 | ***RIGHT*** 185 | 186 | ``` 187 |

In Xanadu did Kubla Khan

188 | ``` 189 | 190 | 191 | #### Case 192 | 193 | Tags should match case (just use lower-case) 194 | 195 | Note that this isn't a strict rule like the previous two, but should still be adhered to 196 | 197 | ***WRONG*** 198 | 199 | ``` 200 | In Xanadu did Kubla Khan 201 | ``` 202 | 203 | ***WRONG*** 204 | 205 | ``` 206 | In Xanadu did Kubla Khan 207 | ``` 208 | 209 | ***RIGHT*** 210 | 211 | ``` 212 | In Xanadu did Kubla Khan 213 | ``` 214 | 215 | 216 | ### Attributes 217 | 218 | Extra information for a tag can be given with attributes in the opening tag 219 | 220 | ``` 221 | Go to Google 222 | Bing is here 223 | My cat 224 | ``` 225 | 226 | 227 | ### Classes and IDs 228 | 229 | Sometimes you'll want to add styling or interactivity to only certain parts of a page 230 | 231 | For example, you might want to make a paragraph look bigger 232 | 233 | We can target specific HTML elements through their `id` or `class` attributes 234 | 235 | ``` 236 |

Lorem ipsum dolor sit amet

237 |

Lorem ipsum dolor sit amet

238 | ``` 239 | 240 | #### IDs 241 | 242 | When do you add an ID? 243 | 244 | A type of element that occurs only once on the page 245 | 246 | e.g. a page header, footer, navigation and main content area 247 | 248 | ``` 249 | 252 | ``` 253 | 254 | #### Classes 255 | 256 | When do you add a class? 257 | 258 | On elements that may be repeated throughout a page 259 | 260 | ``` 261 |
262 | … 263 |
264 | ``` 265 | 266 | 267 | #### Using classes and IDs 268 | 269 | When naming classes and IDs, don't use spaces - hyphens and underscores are fine 270 | 271 | Any element can have more than one class (separated by spaces) 272 | 273 | An element can only have one ID 274 | 275 | Each ID should only be used once on each page 276 | 277 | 278 | ### Marking up with HTML 279 | 280 | HTML has a limited number of tags, as it was originally designed for long, linear technical documents 281 | 282 | It is now used for many things - there aren't enough tags for every possible scenario 283 | 284 | How do you decide which HTML tag to use? 285 | 286 | Tags are semantic - they have different meanings 287 | 288 | There is no right or wrong answer 289 | 290 | View the source code for websites you visit 291 | 292 | 293 | ### Example 294 | 295 | An example HTML page: 296 | 297 | ``` 298 | 299 | 300 | My web page about biscuits 301 | 302 | 303 |

Best Biscuits

304 |

This is a list of the best biscuits

305 |
    306 |
  • Chocolate Hobnob
  • 307 |
  • Ginger Nut
  • 308 |
309 | 310 | 311 | ``` 312 | 313 | #### `` 314 | 315 | Contains metadata about the page 316 | 317 | Where you add the page title, description, and any other relevant information 318 | 319 | Not rendered into the page itself 320 | 321 | 322 | #### `` 323 | 324 | Contains the page content 325 | 326 | Anything you put here will be rendered by the browser 327 | 328 | 329 | ### Validation 330 | 331 | #### What is it? 332 | 333 | Checking the validity of the code (have you followed the rules?) 334 | 335 | Make sure sites adhere to the W3C standards 336 | 337 | 338 | #### Why bother? 339 | 340 | It will eliminate 90% of simple rendering bugs immediately 341 | 342 | Accessibility - With compliant code, any browsing device can render it 343 | 344 | - [http://validator.w3.org/](http://validator.w3.org/) 345 | 346 | 347 | ***Further information:*** 348 | 349 | - [http://www.htmldog.com/](http://www.htmldog.com/) 350 | - [https://www.codecademy.com/tracks/web](https://www.codecademy.com/tracks/web) 351 | - [http://learn.shayhowe.com/html-css/](http://learn.shayhowe.com/html-css/) 352 | 353 | 354 | ## CSS 355 | 356 | CSS makes pages pretty 357 | 358 | - HTML lets us add content - text, images and video 359 | - CSS adds style - layout, colours, fonts 360 | 361 | All aspects of design and layout are covered by CSS 362 | 363 | - Layout 364 | - Colour 365 | - Typography 366 | - Background images 367 | - Borders 368 | - Shadows 369 | - Animation 370 | 371 | 372 | ### Adding CSS 373 | 374 | Assuming we want to style the following HTML page: 375 | 376 | ``` 377 | 378 | 379 | My web page about biscuits 380 | 381 | 382 |

Best Biscuits

383 |

This is a list of the best biscuits

384 |
    385 |
  • Chocolate Hobnob
  • 386 |
  • Ginger Nut
  • 387 |
388 | 389 | 390 | ``` 391 | 392 | #### Styling by tag name 393 | 394 | ``` 395 | h1 { 396 | color: red; 397 | } 398 | ``` 399 | 400 | 401 | #### Styling by ID 402 | 403 | ``` 404 | #intro { 405 | font-weight: bold; 406 | } 407 | ``` 408 | 409 | 410 | #### Styling by Class 411 | 412 | ``` 413 | .ginger { 414 | color: orange; 415 | } 416 | ``` 417 | 418 | 419 | #### Styling multiple elements 420 | 421 | ``` 422 | li { 423 | font-size: 200%; 424 | } 425 | ``` 426 | 427 | 428 | #### Styling things inside of other things 429 | 430 | ``` 431 | .biscuits li { 432 | background: green; 433 | } 434 | ``` 435 | 436 | 437 | #### Grouping styles 438 | 439 | Instead of separate styles for everything: 440 | 441 | ``` 442 | p { 443 | color: red; 444 | } 445 | h1 { 446 | color: red; 447 | } 448 | ``` 449 | 450 | You can combine styles: 451 | 452 | ``` 453 | p, h1 { 454 | color: red; 455 | } 456 | ``` 457 | 458 | (This will apply to all `

` and `

` elements) 459 | 460 | 461 | ### Applying CSS 462 | 463 | #### CSS inline (in an HTML Page) 464 | 465 | ``` 466 | 467 | 468 | My Page 469 | 475 | 476 | 477 |

Hello World

478 | 479 | 480 | ``` 481 | 482 | 483 | #### CSS in a separate file 484 | 485 | index.html 486 | 487 | ``` 488 | 489 | 490 | My Page 491 | 492 | 493 | 494 |

Hello World

495 | 496 | 497 | ``` 498 | 499 | style.css 500 | 501 | ``` 502 | h1 { 503 | background-color: purple; 504 | } 505 | ``` 506 | 507 | ***Further information:*** 508 | 509 | - [http://www.htmldog.com/](http://www.htmldog.com/) 510 | - [https://www.codecademy.com/tracks/web](https://www.codecademy.com/tracks/web) 511 | - [http://learn.shayhowe.com/html-css/](http://learn.shayhowe.com/html-css/) 512 | 513 | 514 | ## Page layout with CSS 515 | 516 | ### Block and Inline Elements 517 | 518 | It's important to know the difference between the two 519 | 520 | 521 | ### Block Elements: 522 | 523 | `

`-`

`, `

`, `