Sunday, 6 November 2016

CSS Selectors

In CSS, apart from just declaring the element selector, you can declare a specific element. For example, if I have many <p> elements and I only want to select a certain <p> element, I can use a specific selector. There is a number of ways of doing this. The first way is to call on the elements id.
I do this by using the hashtag symbol (#), followed by the id name. See the syntax below:


This will also effect every element containing the id "para1" so be careful!

The second way to declare specific element selector is by calling on the class of the element. This is done by placing a .(dot) in front of the class name. This technique is used when you have a group of elements you would like to change. See example below:


Thursday, 3 November 2016

CSS Basic

In this post I will cover the basics of CSS. As I said in my earlier posts, CSS is used to style your webpage. It gives your webpage a 'prettier' and 'nicer' feel.
To begin, you can create a separate style sheet, or you can just place your CSS inside your HTML within <style> tags. I will be using the <style> tags for my example.
Within these <style> tags, you will simply state which elements you would like to style. After this, you will code what style rules you want to change. These style rules will be held within curly brackets {}. Your first declaration, will be to state what you would like to edit (property), followed by the value. See my example below.



In CSS, there is sometimes different ways to declare values, take 'color' for instance. There is three ways to declare a value for color:

            • color: red; - This is declaring it by name
            • color: rgb(255,0,0); - This is declaring it by the formula red, blue and green
            • color: #FF0000 - This is declaring it by Hex. Value
All of the above values will give you the color 'red'.

 It is also possible to obtain double barrel property tags, for example, some of these include:
            • background-image
            • background-repeat
            • background-attachment
            • background-position
            • background-color
            • text-align
            • text-indent
            • text-decoration

Tuesday, 1 November 2016

HTML Lists & Forms

The final part I will cover on HTML is Lists and Forms. As it says on the tin, lists are used to create lists. There are two types of list, un-ordered and ordered. An un-ordered list is used for when it does not matter what order your items are listed in. The ordered list will list your items in ordered numbers.
To create these lists, you will use the <ul> or <ol> tags. Within these tags, you will use the <li> tag to create a List Item. See example below:


Forms are used to give the user a chance to enter some sort of input into your website. This will useful later when we are doing JS as it will enable us to process the users data, but for the meantime we'll just learn how to create forms.
To create a form, you will use the <form> tag. Within these form tags, you will use the <input> tag to create an Input Type. This input type can be anything from a text box to radio buttons. When creating an input, you must state what sort of input it is by using an attribute. e.g. type="text"
See the code and output below for clarification:




Friday, 28 October 2016

HTML Tables & Inner Styling

It is possible to create tables using HTML. The use of this could be to display a timetable on your website. To create a table, you will use the <table> tag. Every table contains Table Rows which can be created using the <tr> tag.
 You will include Table Headings within the <tr> tag, denoted by the <th> tag. Using our example, a table header would be used for the days of the week. e.g. Monday, Tuesday, etc.
Following this, you would use the <td> tag. This tag is used for Table Data. An example of this would be the listing on your timetable. e.g. Room 1 - HTML Lab.
As well as using all these tags, you can include a Caption using the <caption> tag.

Although styling is done using CSS in an external style sheet, it is possible to add style rules within your HTML page directly. This is done by using the tag <style> and inputting your style rules within it. You will then call on whatever elements you wish to style, in my case, the table, th, and td elements. You will then state what you wish to style, an example of this would be the border. Once you have decided this, you will state how you would like to style it. All of this will be contained within Curly Brackets {}. Example:
<style>
       table{
               border: 1px solid black;
       }
</style>

See the example below for using all of these tags I just mentioned.



On the image on the left you can see all the tags I talked about above. Note that I have the same number of <th> and <td> in each of the column. My style rules were declared above, within the <head> tag.
On the image on the right you can see that the <th> tag will display your text in bold, and the <td> tag will display normal text. You can also see the style rules created a border around the table, with the caption being outside the border.

Monday, 24 October 2016

HTML Attributes & Basic Styling

Today I will go through HTML Attributes and basic HTML Styling. HTML elements contain attributes, these provide additional information. They are always declared at the start of an opening tag. Each attribute has a Type and a Value.
Some of these attributes include:

  • lang
  • title
  • href
  • src
  • width
  • height
  • alt
The lang attribute is used to denote the language. The title attribute is used when hovering over the text within the tag, it will display the title. The href attribute is used to add a link to a different html page. Width and height are used to specify the size of an image, and the alt attribute is used to display text if the image is unavailable. See the images below which displays the code itself and the output.


In the right image you can see the code using attribute tags.

To the left you can see the result of these attribute tags outputted to the website.







Aswel as attribute tags, there is some very basic styling you can do using just HTML. These tags include:

  • <b>
  • <i>
  • <u>
The <b> tag makes the text bold, the <i> tag makes the text italic, and the <u> tag underlines the text. See screenshots below.



Thursday, 20 October 2016

HTML Basics

HTML (HyperText Markup Language), CSS (Cascade Styling Sheet), JS (JavaScript) are the very basic programming languages used to create and build websites. On this blog I will help and aid you to use the tools needed to build a basic website. The easiest way to write code for HTML, CSS or JS is to have a text editor. The text editor you use should be able to edit your code and run it through a browser such as FireFox or Google Chrome. The text editor I would suggest is Notepad++. Please find the link below if you wish to download this editor.
We will first take a look at HTML. HTML uses building blocks known as 'Elements' to create a webpage or certain applications. The most basic element tags would be:

  • <body>
  • <html>
  • <h1> ... <h6>
  • <p>
Every HTML document begins with the type declaration: <!DOCTYPE html>
The HTML document itself is contained between the <html> tag, followed by the <body> tag.
Within these tags is where you find the main bulk of your website, which include tags such as your <p> and <h1> to <h6> tags.
Every tag has an opening and a closing tag. This is denoted by a '/' in front of every closing tag. Within the opening and closing tags is where you will type what you want to be outputted on your website.
See the screenshot below for an example.
Download link for Notepad++: