HTML vs. CSS

HTML vs CSS

So you want to build a website?

Learning how to construct a website is much like learning a new language.

The fundamental languages for building a website are HTML and CSS.

Let’s break each one down individually, then see how they work together…

HTML stands for Hypertext Markup Language. Think of HTML as the skeleton or tree of the document. It’s what gives structure to the site in its most basic form. We do this by tags, elements, and attributes. Whether you want headings, lists, images, or links, HTML can do all of that.

We can start with a basic HTML document.

<!DOCTYPE html>
 <html>
 <head>
     <title>Welcome to One Month</title>
 </head>
 <body>
     <h1>Big Willie Style</h1>
     <img src=https://i.imgur.com/Vr37Ac3.jpg>
 </body>
 </html>
HTML vs. CSS

HTML code example

Lets dissect this a bit further. The !DOCTYPE tells the browser what type of document it is. In this case, HTML. In the head section you can see the title tag. This is where you would put the title of your website. Inside the body, you could add an H1 tag. Think of a newspaper headline such as Hello World!. This would be inside the H1 tags like so <H1>Hello World!</H1> which would translate to the largest heading tag there is.

Tag, you’re it!

HTML is the structure of a website. In order to give your website form you’re going to need to use some HTML tags (also referred to as HTML elements).

<h1>, <h2>, <h3>, <h4>, <h5>, <h6>
These tags are for headings, much like a newspaper. h1 being the largest.

<p>
Paragraph

<br>
Line break

<img>
The img tag is for inserting images into your site.

<video>
The video tag is for adding videos, of course.

<a href>
We use this for adding links, stands for anchor.

<strong>
Bold

<em>
Italic

<ul>
unordered lists

<ol>
ordered lists

Note: Both <ul> and <ol> have children tags <li>

If you are writing a list either unordered <ul> (bulleted) or ordered <ol> (numbered) they will surely need items in the list. To do this we use the list <li> tag. The <li> is a child of either the <ul> or <ol> tags. So an example of favorite 90’s sitcoms would look something like this…

<ul>
  <li>Seinfeld</li>
  <li>Friends</li>
  <li>Frasier</li>
  <li>Growing Pains</li>
</ul>
HTML vs. CSS

HTML code example

CSS

CSS stands for Cascading Style Sheet.

If HTML is the structure of your page, CSS is the style. It’s not one or the other, rather they work together at all times.

Without CSS, your websites would look rather boring and dull. In CSS there is a property and a value. Property is what you want to change, property value is what you want to change it to.

Let’s look at our example again…just with HTML.

CSS code example #1

CSS code example #1

Remember the <body> tag in HTML? We can correspond the same body with CSS. Let’s say we want to change the color of the body. It would look something like this…

HTML with CSS code together

HTML with CSS code together

body {
 background: red;
 }

Gettin’ jiggy wit it.

Or lets say we want to change the color and size of just the text in the body.

It would look like this…

body {
 font-size: 25px; background: blue; color: orange;
}

Learn HTML vs. CSS with a blue background Or suppose you just wanted to hone in on the H1 tag. You could do something like this…

H1 {
 color: blue; font-size: 100px
}
 Learn HTML vs. CSS with a blue background
 

With color, we can do it simply such as the examples above. Another option is to use hexadecimals (#RRGGBB).

In order for us to take advantage of CSS, our HTML needs to be linked to it. We do this by…

<link rel=”stylesheet” type=”text/css” href=”main.css”/>

As you can see, there is a relationship (rel) between HTML and CSS.

Another way we can implement CSS is using the font-family property. This is the same thing as using a text editor to change the font.

We do this by…

h1 {
 font-family: Arial
 }
 HTML vs. CSS 
 

Case Study: CSS Zen Garden

A wonderful showcase of the relationship between the two languages is CSS Zen Garden.

CSS examples with CSS Zen Garden

CSS Zen Garden demonstrates the power of CSS. Clicking the links to the right will load the same exact page with one discernible difference, the CSS. This clearly highlight what CSS can do by changing the look and feel of the page.

Here are some examples from the garden…

CSS Zen Garden examples

CSS Zen Garden examples

CSS Zen Garden examples

Tutorial highlights

So what have we learned?

  • We’ve learned how to construct a barebones website using HTML.
  • HTML can exist on its own, CSS cannot, but together is where the magic happens.
  • The more we learn about each language, the more creative we can be with our design. This is the fun part. With the structure in place, the choices are endless when it comes to what we see.
  • HTML is the noun, CSS is the verb. Let’s make sentences!

Learn more HTML and CSS now! 

If you would like to continue your journey with HTML and CSS here are a few resources:

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *