If you are living in the modern day computer world, your second best friend is probably - let me guess - Google, right? Just kidding! But I am sure you have an online presence of some kind - a social media account, a personal blog or maybe even a business.
We spend hours online reading blogs, watching videos, scrolling through Pinterest, you name it. Ever wondered what goes on behind the scenes of those websites you browse? Today’s post gives you a brief introduction on how these websites are created and how to make them look beautiful.
Even if you do not build websites, knowing the basics of HTML and CSS is an incredibly useful skill to have in today’s internet world. So if you are intimidated by the technical jargon, code etc., don’t worry. We will dig into the fundamentals of HTML and CSS and understand how they work together (and we'll also build our own web page!).
What is HTML?
HTML stands for HyperText Markup Language. Just as we, humans, use languages to communicate with each other, HTML is a language of the internet. Web browsers like Google Chrome read and interpret HTML to render the information you request for on the web.
HTML is essentially the building block of every website. It defines the structure of every web page and its content.
Common HTML Terms
While getting started with HTML, it’s important to understand a few common terms associated with the language:
Elements: These are designators that define the order and structure of the content within a web page. <span> , <p> , <div>, <h1>, <title> etc. are all examples of basic HTML elements. Each HTML element is enclosed within a start and end tag as shown below.
<div> … </div>
Tags: The use of angle brackets around an HTML element creates what’s called an HTML tag. HTML tags most often occur in pairs of start and end tags.
A start tag indicates the beginning of an HTML element and looks like this:
An end tag indicates the end of an HTML element and consists of a forward slash as shown below:
Attributes: We use attributes to provide additional information about an HTML element. Some common attributes include id, class, src and href. Attributes are defined within the start tag of an element after its name. Each attribute is defined by a name and a value. For example, the <a> element below includes a href attribute as shown below:
<a href=“http://www.google.com”> Google Search Engine </a>
What is CSS?
CSS stands for Cascading Style Sheets. CSS defines the visual style and appearance of the web pages. So if you see italicized text or a background image on a web page, it is CSS that is doing the trick!
Common CSS Terms
Here are some of the common CSS terms that are useful to know:
Selectors: A selector designates the exact HTML elements to target for styling. Selector generally targets all HTML elements of one type directly or a specific instance of an element, identified by an attribute such as id or class. The styles to be applied to the targeted element are enclosed within curly brackets following the selectors. For example, the selector in the above code is targeting all the <a> elements.
Properties: A property determines the styles that will be applied to an HTML element. There are several properties that are available for use. Some of the common properties are font, background-color, size and color. In the example above, we are using the color, font-size and font-weight properties to style the <a> element.
Values: Each property has a value associated with it. The value defines the behavior of the property. For example, the value 14px defines the behavior of the font-size property.
What is the difference between HTML & CSS?
Even though very often HTML & CSS are used together in the same context, they are far from being the same. While HTML defines the structure of the web page, CSS defines the style and appearance.
To make this easier to understand, let’s compare a website to a house. HTML is like the bricks that make up the house while CSS is the paint and decor that makes the house presentable and beautiful.
A webpage can exist without CSS, but never without HTML.
Develop a Simple Web Page Using HTML & CSS
Now on to the exciting part, let’s build our own web page. It is a super simple and fun activity!
You will need:
- A Text Editor to write the code for your web page. Some of my favorite code editors are Sublime Text, Notepad++, Brackets.
- A Web Browser to view your web page. Anything from Google Chrome to internet explorer will do.
Create a folder and name it. I am going with MyWebPage1.0 for mine.
Create a text file inside the folder and paste the following HTML code in it. Name it as Webpage.html and save as an HTML file type.
Next, create another text file inside the folder and paste the following CSS code in it. Name it as style.css and save it as a CSS file type.
That’s it, now double click on your HTML file to run it on your web browser. Here’s a screenshot of the webpage you can expect to see on your browser.
And there you go, you’ve created your first web page! Feel free to play around by changing the HTML and CSS code to alter your web page. The best way to learn HTML and CSS is to really just experiment and have fun exploring the various possibilities that they offer.
About the Author
Chaitra is a creative geek who thinks coding is fun! Living in Seattle, she runs her own design & photography studio called PinkPot that aims to help passionate creatives build a kickass online presence. She specializes in creating websites that are not only beautiful but also offer a rich and friendly user experience. More often than not, you will find her either coding her way through the web, capturing beautiful moments on her camera or laughing away with her geeky husband over a cup of coffee!