Search This Blog

Friday, November 17, 2017

CSS Tutorial Part 1: How To Use Or Apply CSS

Hello guys, as promised, we're going to learn how to style our website using Cascading Style Sheet or CSS in this lesson. This lesson is for those who had been following my tutorial on HTML programming or those who already know the basic of HTML. If you're unsure of what I'm talking about, then you should probably go to HTML tutorial first. You can do so by clicking here.

CSS consist of 3 important parts which are selector, properties and value. Basically, selector is the target of our styling. Most off the time, we will be using HTML tags such as <p>, <a>, <h1> etc as our selector. Properties are the property we want to style such as font-size, color etc while value refer to the value of the Property (i.e. red, blue, 12px, etc)

There are 3 ways to apply CSS to our website which are the rarely used, inline, the normally used, internal and the most commonly used, external. Lets start with the inline method.

<p style="color:red">your text</p>

The inline method is where we put the style directly into a HTML tag. In this case we don't need to specify a selector as the style is in the styling target itself. The properties here is color which refer to font-color while the value here is green. When using CSS, always remember the format, properties followed by a colon ':' followed by value. Also notice that the style attribute is placed to tell the browser that we're using CSS.

The inline method is pretty useful in some case but we would normally avoid it as we want to keep out HTML file clean. The next method, internal is slightly better is than inline as it didn't mess our HTML file that much. To do this, we simply use style as tag like we would with HTML tag. However, as styling is not in the target itself, we need to specify the selector.

<style>
p{
   color:red;
   /* other style for our paragraph */
}

h1{
   /* some other style we want for our heading */
}
</style>

we can put as much style as we want and for anything we want this way, just remember the format. Basically anything within the curly braces are the style for the selector before the curly braces. Also make sure to put a semicolon ';' at the end of each style like this color:green;. The <style> can be placed anywhere in the HTML file but we normally put it in the <head> tag.

The last also the most popular method of using CSS is to create and external file for CSS and link it to our HTML file.

Your CSS file should looks something like this.

p{
   color:red;
   /* other style for our paragraph */
}

h1{
   /* some other style we want for our heading */
}

It is same as when we're using the internal method but without the <style> tag. We can put as many style as we want in here and save it as css file (i.e. main.css).

To link our CSS file to HTML file, just open the HTML file and write the following code in the <head> tag.

<head>
   <link rel="stylesheet" href="main.css" />
</head>

link tag is used to tell the browser to look through the content of an external file. the attribute rel="stylesheet" tells the browser that the file type is stylesheet which also means a CSS. The href="main.css" attribute specify the path to the file. If the file is in the same directory as the HTML file we're linking with, we just needs to put in the file name instead of a full path. Lastly, notice that there is a forward slash '/' at the end of our link tag. Basically it means that our tag are self-closing. Self-closing tag are tags that don't comes in pair of opening tag and closing tag like most of HTML tag.

Btw, the /*  */ is used to write a comment, your browser will ignore anything written is in. Though it might sound pretty useless right now, it is actually really useful when you're working with a huge website as you can label what each parts of the code do so that you won't need to read through the whole code when there is a bug. Just make sure you don't overuse it.

Now that we know how to apply style to our our web page, we'll start styling our web page in our next tutorial. See ya.

Wednesday, November 15, 2017

HTML Tutorial Part 3 : Creating A List In HTML


Hello again everyone, this is our third HTML tutorial for beginner web developer also our last (at least for the beginner parts). In the next post, we will be learning the basic of CSS instead.

In this lesson we will learn about list in HTML.There are 3 type of list that we can use in HTML but only 2 are relevant for our beginner tutorial. The 2 type of list are ordered list and unordered list which are basically a numbered list and a bullet list respectively. The tag <ol> and <ul> are used to create the list and as always, a closing tag is required to use the tag. These 2 tag are used in pair with <li> tag which is used to specify the list item. Modify your HTML file as below,

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <ul>
      <li>Home</li>
      <li>About</li>
      <li>Contact</li>
    </ul>
    <h1>I'm a beginner web developer</h1>
    <h2>This is my first website</h2>
    <p>I'm sooo excited</p>
    <p>I'm going to keeps on following the 
      <a href="https://amirruddin-razak.blogspot.com/">tutorial</a> 
         and make my own super cool website
    </p>
    <ol>
      <p>Follow the tutorial here</p>
      <li>On Blogger</li>
      <li>On Google+</li>
    </ol>
  </body>
</html>


What the <ul> tag do is simply tells the browser to create a bullet list for every single list item, <li> tag enclosed by it. The <ol> tag did pretty much the same thing but with a numbered list instead of a bullet list. Any texts or items enclosed by a <li> tag will be listed in your browser. Notice how I put a <p> tag in between the <ol> tag. What this gonna do is that the browser will display "Follow the tutorial here" normally without being numbered. This is because the text is not enclosed in <li> tag. Therefore the browser won't treat it as a list. But because the <p> tag is in between the <ol> tag, the displayed paragraph are indented as if it is a part of the list. Try to save the HTML file and you should see something like this,

Displaying results of using Ordered list and Unordered list HTML tag in browser
That's about everything on creating a list in HTML. Before we end this lessons, let's touch up our website a bit by making our list into a link by using the anchor tag we learnt before. Modify your code,


<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="about.html">About</a></li>
      <li><a href="contact.html">Contact</a></li>
    </ul>
    <h1>I'm a beginner web developer</h1>
    <h2>This is my first website</h2>
    <p>I'm sooo excited</p>
    <p>I'm going to keeps on following the 
    <a href="https://amirruddin-razak.blogspot.com/">tutorial</a>
       and make my own super cool website
    </p>
    <ol>
      <p>Follow the tutorial here</p>
      <li>
        <a href="https://amirruddin-razak.blogspot.com">On Blogger</a>
      </li>
      <li>
        <a href="https://plus.google.com/105989137850183491401">On Google+</a>
      </li>
    </ol>
  </body>
</html>


Now save your file and all the link should be working now except for About and Contact since you don't have an About page and Contact page yet. But you should be able to create the 2 pages easily by using what we've learnt before. Just make sure the name of your HTML file match the name you put in your link else the link won't works. Also notice that I put a '#' instead of a url or a file name in the link to home. Basically the '#' is used to do nothing, you will stay on the same page even if you click the link. Since you're already on the home page anyway, its only natural that you won't be sent anywhere if you click the link to home.

your website now looks like this,

List item displayed as link

That's all for this lesson, in the next lesson we will be learning how to use CSS to make our website looks like a real and beautiful website.

If you have a question about HTML, feel free to ask me in the comment below. see ya

Tuesday, November 14, 2017

HTML Tutorial Part 2 : Headings And Anchor

Hi everyone, in this tutorial we going to cover 2 more important tag in HTML. Once we're done with this, you should be ready to create your website and we will be starting our CSS tutorial to make our website looks better. Of course HTML has far more tag than this but we will leave all those complicated things for later as they are not really useful for us (at least for now).

The first tag we going to talk about is heading tag. Basically heading tag is use tell browser "this is a heading so display it in a large size".There are 6 different font size you can choose for your heading by using <h1> to <h6> tag with <h1> being the largest and <h6> is the smallest. As always, each tag needs an open and closing tag so make sure you pair each of your <h1> <h2> .... tag with </h1> </h2> .... tag. To show how it works, open the HTML file we created in the previous in your text editor and edit it as follow,

Codes to create heading

Notice how I only use <h1> and <h2> here. Normally, we only use <h1> up to <h3> in a website because your website will looks really weird if you have like 6 different size of heading there. Also, if you notice, I also make an indent before each tag I put between the <body> tag. It is not required to make the indent but it is a good practice to do them as it will make your HTML file cleaner and easier to read. This way, your will know which tag is inside which with just a glance. Once you're done editing, save your file and refresh your browser. you should see something like this in your browser.

Displaying results of HTML heading tag in browser
There are now 3 different size of text with the largest being the text enclosed in <h1> tag followed by the one in <h2> tag followed by <p> tag. Now that you know how to make a heading, lets talk about anchor tag.

Anchor tag is used to make a link to a certain place but unlike other tag, anchor tag has an attribute and value which specify where the link is connected to. For example,

Codes to create anchor tag or link in HTML


The <a> is the anchor tag and it is followed by a closing tag. Anything in between the opening and closing off anchor tag is what you want to make into a link, it can be a text or even image. In this case, we make the word 'tutorial' into a link. Notice there is an extra text in the <a> tag. the href is an attribute which is the hyperlink reference. It means that any value given to this attribute is the target of the link. The url in the quotation mark is the value of the attribute which means it is the target of the link. Note that quotation mark is always needed to give value to an attribute. 

Now lets save the file and refresh your browser, you should get something like this,

Displaying results of HTML anchor tag in browser

The word 'tutorial' had become a link and if you click it, it should sent you to the url we put in the anchor tag earlier. The underline and colour for the word 'tutorial' is the default style for links, we will learn how to change them later in CSS tutorial.

If you got any question about what we've learnt so far, feel free to ask in the comment below. see you in the next tutorial.


Sunday, November 12, 2017

HTML Tutorial Part 1 : Creating A HTML File

Hello guys, first of all, I'm sorry for the late update, I've been really busy with assignment and such. Anyway, let's get started with our Begineer Web Developer Tutorial.

The first things you going to learn is HTML or Hyper Text Markup Language. Basically, HTML is a language you use to show the content of a website in the browser. Which mean HTML simply helps you to show a bunch of text and that's all. It might looks ugly for now but trust me, its pretty useful, and once you learn CSS later, it will be beautiful as well.

First of all, you gonna needs a text editor. Things like Notepad would be fine but I would suggest you to use a Sublime Text or a Notepad++ (this is what I'm using) instead as they have a lots of function that will make your life easier. Whatever you do, don't ever use Microsoft Words for creating a website, just don't.

Now that you have gotten yourself a text editor, let's create our very first website. open a new file in your text editor and copy test code.

Code for creating HTML file

now save your file as index.html and open the file with a web browser. Of course you wouldn't see anything yet on your web browser because all we did was creating a HTML file. A HTML file is actually just a bunch of text enclosing the content. Each tag will be enclosed in the less-than '<' and greater-than '>' symbol. Aside from the selected few, all html tag will have a opening tag and closing tag

Notice how I use two tags here, the first one is <!DOCTYPE html> which is used to tells the browser that our document type is HTML. the second tag I use is <html> which is an opening tag and is followed by </html> which is a closing tag. The '/' symbol in the tags simply means that the tag is a closing tag. The <html> tag is the single most important tag in html file or your website. Basically, anything in between <html> and </html> is the content of your website. Now let's write something on your website.

Edit your html file using your text editor so that is become something like this,

Code for using body and head tag in HTML


save your file and refresh your web browser. You should see something like this,

Displaying text in browser as results of HTML codes
What really happens here is that we use <head> and <body> tag to divide our html file into 2 parts, the head and the body. The <head> is where you put all the information about your page that you want to tell the browser about while the <body> is where you put all the information you want to show to the user who visited your webpage. Notice how both <head> and <body> tag has a closing tag </head> and </body> respectively. Anything you write in between the <body> tag will be displayed on browser as a bunch of text with no formatting whatsoever. So what we gonna do is to give it a format.

Codes for creating paragraph in HTML

Edit your html file, save it and refresh your browser and you should get something like this

Displaying results of HTML paragraph tag in browser
What our codes do is really just giving our text a format, the tag <p> stand for paragraph like the one you use when writing an essay. Anything in between <p> and </p> is considered a single paragraph and the next <p> tag will be another paragraph. A webpage can only has 1 <html> , <body> and <head> tag each but it can have as many <p> tag as you want.

That's all for this entry, we will talk about other formatting text next time. See you later.



Sunday, November 5, 2017

Introduction

Hello guys, its my first post and I thought I should tell you a bit about the purpose of this blog before starting the tutorial.

Well, basically this blog is for those who wish to be a web developer but had taken the wrong path (i.e. getting a degree in other unrelated field like me) or those who want to be a web developer but don't know where to start. Though I couldn't guarantee that you will be getting a job as web developer by following my blog, I can at least teach you some of the skills you will need to get a hired (at least for those in Malaysia).

Before we get started with the tutorial, let me clarify a few things. First, in this tutorial, I will only be covering the important part of HTML and CSS. As for other things like Javascript, SEO etc, I''ll try to include them in my tutorial if I can. secondly, I'm not a professional web developer yet (still a student) so all I could do is teach you basic skills that all web developer needs. 

As far as I know, web developer is divided into 3 major category:
  •  Front-end Developer - They works with HTML, CSS and JavaScript along with some libraries like JQuery and frameworks like Bootstrap. These people are responsible for creating everything you can see on your browser. All the interface, font size, font color, background color, image etc.
  • Back-end Developer - They works with server-side language like PHP, C# etc. These people are responsible for data and system management (things you couldn't see on the browser. i.e storing your personal information for your email, comparing the password you type with your email password or making web application etc).
  • Full-stack Developer - They are the combination of Front-end developer and Back-end developer.
You can choose whichever path you want to take and research them. But no worries, everything I will cover in this tutorials are the things that you have to learnt no matter which path you want to follow. So, for now just relax and enjoy my tutorial. That's all for now, I'll be updating my first tutorial on HTML soon.

By the way, I'll be following the Back-end path. Wish me luck