HTML Document 2

aight here goes some more html. and yea btw tables are hard so u'll need to practice them a lot. dont worry, they arent used much, and when you cant remember something, googling is handy in those occasions ;)


Table of contents:


Lists: Ordered or Unordered

Lists are used to list stuff. Like when you have a list of items, you can use HTML to display them in an unordered (bulleted) and ordered (numbered) list.


My Favourite Fruits:

Unordered Lists:

Unordered Lists display their items in a bulleted form. The ul tag is used to create an unordered list. An li tag represents a list item, which is contained inside the ul tag of the list.

Following is an unordered list:

The code behind this list is:

Ordered Lists:

Ordered Lists are written like unordered, except for that the <ul> and </ul> is replaced with <ol> and </ol> respectively. Ordered lists produce numbered list items:

  1. List Item 1
  2. List Item 2
  3. List Item 3

The code behind this list is:


Tables

Tables are used to present data in a tabular format. Following is a table of marks of three students

NameMarksTotal
Joe79100
Rick56100
Imran Khan1100

Table borders:

By default, tables have no borders, but you can add one by using the border attribute to the table tag.

Following table has border="1" attribute in its table tag:

NameMarksTotal
Joe79100
Rick56100
Imran Khan1100

The table tag of the above table is:

<table border="1">
    <!-- code !-->
</table>

Looks ugly right? Well you can use CSS to make it look way better.

HTML Comments

Whats a comment? Like Share Subscribe comment? Nope. Comments are parts of code, which aren't executed. They are used for informational purposes only. Like you can leave a note for someone, or for yourself... there are many possibilities. The <!-- code !--> you saw above, was a comment, and was used to show that the interior of the table tag was written here.

How do you make a comment? Every language has comments. Whether it's PHP, JS, C, C++, C#, Java, CSS, etc. The method of writing a comment is pretty similar throughout every language, but here in HTML, it's different.

Though you don't need to worry about remembering the method for it. Your text editor (like Sublime Text) will automatically take care of it when you press it's hotkey. Usually, the shortcut is Ctrl + /.

When you write a comment in HTML, you enclose that desired part of code with <!-- and !--> Text editors represent a comment with grey color.

Comments are really, really, really common, so I thought it would be important to know about comments at this stage. Now, back to tables.

Table width:

Similarly, you can use the width attribute to change the width of the table. Following is a table with border="1" and width="500" attributes:

NameMarksTotal
Joe79100
Rick56100
Imran Khan1100

How to write a table? Table Stucture:

Writing a table is hard work :/, but i'll break it down into simple steps for easy understanding!

Now, we have a table:

NameMarksTotal
Joe79100
Rick56100
Imran Khan1100

Let's see its HTML first:

Overwhelming right? Don't worry, once I tell you the basic stuff, you'll start noticing things:

tr is table row
th is table heading
td is table description

Are you bored?

Rows are in horizontal direction, and Columns are in vertical direction.

  • As you can see, this is a 4x3 table. It means it has four rows and three columns.
  • tr tag defines a row. As you can see, there are 4 tr tags in the above table. It means it has 4 rows
  • For each row, there are 3 th and td tags. th is table heading. It represents a heading of a column. As you can see, the th tag only encloses the heading of each column, not its description. Three th (table heading) tags in one tr (table row) define that this table row has three columns
  • td tag describes the description for each column. The data is enclosed in td tags because they define the desciption for each table heading
  • Now i know you couldnt understand anything above, so let me show you this cool little HTML editor, in which you can edit stuff anyhow you want. The results will update as you type. This way, you might get a little understanding of the table tags:

    output will be displayed here

    Try changing some stuff in the above HTML editor!