Basic Web Technologies
The basics of how webpages work
Anatomy of a webpage
Webpages consist (mostly) of 3 main components
HTML
The Skeleton of a webpage (nouns)
JavaScript
The muscles/nervous system of a webpage (verbs)
CSS
The skin/clothes of a webpage (adjectives)
HTML
Any nouns on a webpage are typically html (i.e. that block of text, that image etc.)
What Does HTML Do?
HTML is a markup language, this means it's only job is to say how data should be organized. None of the data processing takes place in HTML
How do you write HTML?
HTML is a collection of tags and attributes, tags are the most general way of saying how you want something to appear and attributes set special behaviors for tags
Each tag has an opening tag (<tag>) that is two angle brackets with the tag name inside. Followed by the content of the tag (i.e. some text), and finally the closing tag which is the same as an opening tag with a forward slash (</tag>)
Any attributes are added in the opening tag before the second angle bracket; <tag attribute='value'></tag>
HTML Example
<p>This html gives you regular text</p> <h6>and this html gives you larger text</h6>
Which results in:
This html gives you regular text
and this html gives you larger text
Here are some common HTML tags
But first, if you ever see <!-- some helpful text --> this is a comment in HTML it's just there for your benefit the browser ignores it
Heading Tags
Heading tags are used to create larger text, they are a h with a number and get smaller as the number gets larger
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
Paragraph Tags
Paragraph tags are used to create smaller sized text and typically contain longer content, they are denoted with a p
<p>paragraph tags</p>
Also emphasis (<em>) and strong (<strong>) tags can be put inside paragraph tags to add italicization and bolding
Likewise anchor tags (<a>) can be used to add links in text (with a href attribute); <a href='https://google.ca'>google</a> gives you: google
List Tags
You can make a bullet point (unordered) and/or numbered (ordered) list in HTML using the ul and ol tags with list item (<li>) tags inside
Example:
<ul> <li> A </li> <li> B </li> </ul> <ol> <li> C </li> <li> D </li> </ol>
Which results in:
- A
- B
- C
- D
Divider Tags
Divider (usually called div) tags are used to organize other groups of tags together, for example all the text in this slide is inside a <div>
Some people also use section tags; <section> to do a similar thing. These slides actually use a section tag with a div inside it:
<section class='bg-facebook'><!--The bg-facebook thing is not part of HTML it's part of what i'm using to make these slides--> <div> <h2><strong>Divider Tags</strong> </h2> <p> Divider (usually called div) tags are used to organize other groups of tags together, for example all the text in this slide is inside a <div> </p> <p> Some people also use section tags; <section> to do a similar thing. These slides actually use a section tag with a div inside it:</p> ... </div> </section>
Image Tags
Last but not least are image tags, these are special tags because they don't need to be ended and all they need is a src attribute with a path to the image you want to use (also width and height are useful attributes)
<img src='./path/to/image.png' height='300px' width='300px'>
JavaScript
Any verbs on the website are typically JavaScript (i.e. That disappearing navigation bar, that transition animation etc.)
What Does JavaScript Do?
JavaScript is an in page programming language, meaning anything that happens on a webpage without needing to reload is typically JavaScript
For example the slide transitions on this presentation are all in JavaScript
Plain Script Tag
The first way to use javascript is by writing it in an HTML file using a script tag
<script> var greeting = "Hello World!"; console.log(greeting); // Sends the greeting variable to the browsers' console </script>
Link Script Tag
The second way is to link to a javascript file using the src attribute and a URL or path to a .js file
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js"></script>
This allows you to bring in a javascript file as if it was written using a plain script tag
CSS
Any adjectives on the page are typically CSS (i.e. that white text, that large text etc.)
What does CSS Do?
CSS is a way of defining what HTML tags look like, for example you can specify that all paragraph tags should be a certain color, or all heading 2 tags should be a certain size
You can also target specific content by using the id or class attributes on those tags, more info on that here
Style Tag
You can write CSS in an HTML document inside a style tag
<style> p{ font-size: 40px; } </script>
Link Tag
You can use a link tag to import existing CSS from a URL or a path to a .css file
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.8.0/css/bulma.css"/>
Questions?
If you have questions submit them on my website:
Ask Questions
Also if you want more free coding content check out Canadian Coding