What is a Website?
At its most basic level, a website is a collection of files inside folders that visitors can access when they type an URL into their browser. Just like how you keep your files in folder structures on your computer, websites keep pages of their site in folders too - the main difference is that with websites, the folders live on the Internet (saved to a remote server).
For example, a file path on your computer could be something like this: file:///Users/sarahlesh/mywebsite.html. This file structure is telling your computer: go into ‘Users’, open the folder ‘sarahlesh’, and then in that folder open ‘mywebsite.html’.
It’s the same process with a webpage; instead of file:///Users/sarahlesh/mywebsite.html, the file path on a website would be something like: http://www.sarahlesh.com/sarahlesh/mywebsite.html.
And similar to how a .doc extension signifies a document file, .html signifies an HTML file, or a webpage.
Hypertext Markup Language (HTML)
The structure of any website is created using HTML. Think of it as the structure of a house, where the foundation and skeleton give it shape.
HTML lays everything out by defining the content and flow (the design comes later). It outlines paragraphs, headers, quotes and lists - similar to how you would format a Word document. HTML gives us a way to create the semantic structure for the components of our webpage.
Semantics are defined by the Merriam-Webster dictionary as “the meanings of words and phrases in language”. Just like how semantics in English literature dictate where punctuation must go and how phrases are organized grammatically, the semantics of HTML also dictate how you must write code so that a browser can understand how to display your information..
Here’s the basic structure of a line of HTML code:
- Opening tag: < the name of the element >
- Content: Following the opening tag, we insert the content we want to present.
- Closing tag: < / the name of the element >
An example of this would be:
In the example above, the entire line is considered an ‘element’. The <H1> is an opening tag while </H1> is the closing tag, and sandwiched in between them is the content. The letter ‘H’ signifies your element is a header, and the ‘1’ signifies it’s the most prominent header on your website page. Therefore, an <H2> tag would be slightly smaller and less prominent than <H1>.
Every website has an <H1> tag because it represents what the web page is about and is important for screen readers. Google also weights the <H1> tag heavily as an indicator of the kind of content on that webpage.
Let’s breakdown HTML
Head vs. Body
The <head> (not to be mistaken with <header>) is where we put information about our website. The <body> is where our actual content goes. For example:
<title>this is the webpage’s title</title>
<p> this is a paragraph</p>
<h1>this is an important header</h1>
<h2> this is a less important header</h2>
<h3> this is an even less important header</h3>
<img src="path/to/image" alt="this is an image">
Notice that the <img> tag didn’t have a closing tag; that’s because some tags don’t contain content, but rather list a source. These are called self-closing tags. The <IMG> tag is an example - there is no text being displayed, but rather the tag tells your browser to display an image (which is a type of source) from another place online where it’s being hosted.
Sifting through lines and lines of code can become confusing, which is why many developers use programs like Sublime Text or Atom.io (free to download and use!). They make code easier to read by using colours to distinguish between different aspects of your code. These programs also catch your errors - similar to spell check in Microsoft Word.
You can use the ‘web inspector’ to view, study and change the code of any webpage, and play around with it to learn about coding. Simply right-click a webpage in any modern browser and select “Inspect” from the drop-down menu.
Note: when using the web inspector, make sure you don’t refresh the page - this resets everything and your edits will be lost!
The web inspector feature is symbolic of the open-source culture surrounding web development.
“The nicest thing about web development is that we love open-source, we love sharing,” developer Sarah Lesh said. “The more you dig in, the more you see there are people sharing their expertise and they want you to build on it - that’s why technology has come as far as it has.”
Why do we need other languages other than HTML?
HTML was initially designed as a way to write and share research documents online. And webpages designed with only HTML look as boring as you’d expect a research document to look!
While you can build a website with HTML alone, in this modern age we want our websites to look pretty. To accomplish this we need to use another language called CSS.
Cascading Style Sheets (CSS)
For the most part, CSS doesn’t contain any content. Rather, it’s used for styling your existing content outlined in your HTML code. It describes how you want something to be presented, and declares the style of certain elements that your browser then follows.
If HTML forms the outline and structure of a house, CSS is the design; the walls, the colours and the furniture. The designs we choose affect how we structure our house, but we wouldn’t build the design into our structure.
CSS code is typically kept in a style sheet (a .css file) that is separate from your .html file. The .css file is then linked through your <head> tag. This is best practice. However, below we’re going to use <style> tags within HTML code to demonstrate how CSS works.
CSS is made up of ‘rules’. <style> tags are used to tell your browser that you’re now using CSS, and not HTML. Every CSS rule, which defines how content is displayed, is written on a separate line. This is how CSS works: it selects the element you want to style, declares the property you want to edit, and gives it a value.
For example, below we are selecting a paragraph as the element we want to style, declaring the property of ‘color’, and giving it a value of ‘pink’. This would make the text of this paragraph pink.
If you were to write another CSS rule underneath the one shown above - let’s say a rule to make the text purple - it would overwrite the initial rule. The bottom rule always gets preference with CSS.
Like HTML, we can see what CSS rules are being applied to our website with the web inspector.
CSS is what allows websites to be responsive. Responsive design means that the elements on a webpage increase and decrease in size depending on the device being used to view it.
Responsive websites look good and are easy to read on any device, whether it’s a computer or a smartphone. This is really important, as mobile web use is becoming the dominant form of internet usage and if your website doesn’t have responsive design, it will be inaccessible to the majority of visitors.
Responsive sites also get a better ranking from Google, making them SEO-friendly. You can check whether Google finds your site mobile friendly here!
You can also test your website's responsiveness by changing the size of your browser window (e.g., drag your browser window smaller and larger with your mouse).
Java Script (JS)
JS is used for interactions on a website like opening a pop-up window, validating a login, or getting information from another site to display on yours.
We hope we helped you wrap your head around HTML, CSS and JS!
Want to learn more about coding? There are great free and paid resources available.