🧱 HTML: The Structure of Your House
Every website you view in a browser (Firefox, Chrome, Edge) is literally served to you as a simple text file. For real.
From the smallest of mom-and-pop websites to the largest imaginable infrastructure, the end result at the end of the day
is a simple text file delivered to your browser in the language it learned first, HTML
, which stands for
HyperText Markup Language
, and that's only useful to know for trivia night with the guys.
Like any of the languages we're going to cover, HTML
is just a set of
predefined words and symbols that do special things when
read by a browser. It's been a fundamental part of the internet since the first web browser, with a primary purpose of
displaying, organizing, and linking to content on the internet.
You seem pretty important, so you probably need a way for the world can hear your incredible insights on that one thing
you're really into. You need your very own webpage, and to do that, you'd start with new pal HTML
.
Go ahead and dink around with running this...
<!DOCTYPE html>
<html>
<body>
<h1>Hello World! I have a webpage!</h1>
<p>I'm really into _____ and you should come back, as I'm going to make this thing awesome.</p>
</body>
</html>
Whoa, look at all those <>
things! Those are HTML Tags
, and those are the ways we add structure to our content. The
<h1>
tag, is like a big, bold headline, whereas the <p>
tag is smaller paragraph text. Each tag has an open and a
close tag and stuff in the middle. It's like a delicious Oreo, but without all those pesky carbs. HTML
is filled with
tags like these, and they each serve a different semantic purpose; that is to say they help to organize a document in a
way that makes sense for humans, screen readers, and search engines to read in a predictable and hierarchical fashion.
So, to keep with our <h1>
tag as an example, there are similar sibling tags <h2>
through <h6>
— each getting
progressively smaller and less important by default. When constructing an HTML
page, it's often good to ensure that
you're choosing the right tags to build a sensible hierarchy. Doing so gives you a fighting chance of separating your
content from your styling (which we'll get to later) and, as stated above, helps to keep things organized for whatever
medium is trying to consume your content. After all, on the internet, content is king.
To run an HTML
file on your computer, copy the code above, paste it into a text editor (something like Notepad, not
Microsoft Word) and save it as whatever.html
. Open that file with your favorite web browser, and suddenly you're some
kind of freakin' internet shaman, with a website displaying in a real browser.
🧠 Learn More About HTML:
> Code Academy: Learn HTML
> Mozilla: Getting Started With HTML
But how do we make it look better than this crap? Enter CSS...
💅 CSS: It really ties the room together
So, HTML
describes the content on a page. It's got all the structural elements and some basics like background and
font colors, but by itself, it's quite bare when it comes to the pizazz you're used to seeing on the internet. This is
where CSS
comes along to really tie the room together, like a very tasteful rug that's free of stains from the darn
kids who spill all the time...sorry...I digressed there for a moment...anyway...
CSS
stands for cascading style sheets
, and this is a reference to how you can utilize various rules to overwrite
styles for different scenarios. You know when you resize your browser and the same website shifts all around and shrinks
or readjusts to fit your now-smaller window? That's CSS
at work, and because your browser window is now smaller, some
responsive media queries
have kicked in and overridden the default styles for the site.
Just like HTML
, CSS
has its own special way of communicating with the browser. If we wanted to style our website
above in the most basic way, we could do something like this:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: red;
font-size: 30px;
}
p {
color: blue;
}
</style>
</head>
<body>
<h1>Hello World! I have a webpage!</h1>
<p>I'm really into _____ and you should come back, as I'm going to make this thing awesome.</p>
</body>
</html>
With the code above, any <h1>
on our site will be red and 30 pixels high, whereas all <p>
tags will remain their
default size and be blue.
CSS
is quite powerful and is not limited to just colors and font sizes. CSS
is often used to control the position
and size of elements on the screen, various visual states of things like form fields, and how a single HTML
page can
transform depending on the size of a user's browser window.
Fun fact: Each browser tends to have its own way of interpreting CSS
. While this has gotten significantly better in
recent years, I should note that this seemingly bespoke handling of CSS
has directly contributed to new and whimsical
combinations of swear words previously thought impossible. So before you really dive into CSS
, make sure the kids have
their earmuffs on.
🧠 Learn More About CSS:
Level Up Tutorials: CSS
Code Academy: Learn CSS
After you grasp how to make things look good on your site, you begin to notice that much like your 14-year-old beagle,
it doesn't really do anything. If you want your website to have a greater degree of interactivity, you're going to
need a third layer added on top. Enter the almighty Javascript
...