How To: Web Development 04 - Styling Pt 2

Web Development 04 - Styling Pt 2

Welcome back Null-Byters! You finally have the pre-basics of CSS and we can begin with styling our web page. If you did not read our last adventure, I suggest you go and read it.

Heads Up: Attributes in HTML are the little additions to a tag. They go inside of the opening tag. Examples are: style, width, and height

Step 1: How to Compose a CSS 'Rule'

A rule in CSS are the styles applied to an element. To create a rule there is a basic syntax. Later in this series we will be going over more advanced CSS such as media queries. The basic syntax is as such:

The selector is just the element we want to select. Let's go back to our first webpage. Say we want to do something with the h1 header. There are multiple ways to do it.

Here, we are selecting it based on what it is. This is so vague that it will choose every h1 header we have. As long as it doesn't get overwritten. Here, we are creating a class attribute in our HTML element. We then can use the class selector to select the element in our web page. Here is an example.

Here, we added the class attribute to our h1 header. Now, in CSS using the '.' and the class we set, we can add styles through that. Another way to add styles is with the id. It is similar to the class notation but carries more weight.

There is one more way we can add styling to an element. This carries the most weight and over writes everything. Using the style attribute.

Changing Fonts

Now I think the default font is pretty bland. I want to add a font from Google Fonts! Because I am doing this on a linux machine, I think I will use Ubuntu.

Now click "Add to Collection". And you should see this popup. Hit use on the little bar in the top right.

You can choose the types you want. I will just use the regular one. Scroll down and it will give you a link tag. Copy and paste that into your head section on your web page.

You may be asking yourself, "How do I use this?". First, create a folder named css and add a file named master.css. Now, add a class attribute and name it something in the h1 header.

Now go into that master.css and setup a rule that will style through a class selector.

To add a new font, we need to use something called the font family. In css you just put font-family: 'Name of font', 'Backup font if the other fails';

Now you go over to your webpage and refresh to see your new font. Then you get disappointed because it didn't work. First, you have to link the css file over to your html. You just need to use the link tag. Now put this in your head tag: <link rel="stylesheet" href="/css/master.css" media="screen" title="no title" charset="utf-8">

  • rel means the relationship. In this case, the file is a stylesheet so we put that down
  • href mean hyper reference. This is the path to the file.
  • media is something you can ignore for now
  • title can also be ignored for now
  • charset is just the characters used. Just set it to this to be sure there are no errors.

Now your new font works!

Sorry this was longer than my other ones. Next couple tutorials will be on CSS and HTML then we will move onto JavaScript and jQuery.


Just updated your iPhone? You'll find new features for Podcasts, News, Books, and TV, as well as important security improvements and fresh wallpapers. Find out what's new and changed on your iPhone with the iOS 17.5 update.


Keep up the great work mate :)

Help me understand this one, i have marked them in the image, Tried it but mine fully extends including the RED part i have mentioned.. Thanks in advance ^^

I'm sorry, I don't completely understand. What I think you are asking is why there a black bar even when you zoom out. When programming in CSS, you wan't a variety of device screens. One size does not fit all. So you add dynamic CSS. In this case, it was something called min-width (I will also go over this in a later tutorial). Min-width is that the element can get bigger and bigger but can't get smaller than a certain designated width.


Try zooming in to null-byte website then zoom out, you will see the head

Here, hopefully this helps , now see in the header even though i zoomed out "WonderHowTo" and rest of the "menu" stays centered while black strip extends itself depending on resolution

Ahh, I see. In that case, what Null said is 100% correct.


That is because the menu (main part of the header) is a fixed width. Where as the wrapper outside of the menu is set to automatically fill whatever space is left, depending on the monitor size. Example:

Image via

Thank you NULL and you too PROGRAMZERO for the help , will you make php tutorials too?

Yes, absolutely!


Share Your Thoughts

  • Hot
  • Latest