HTML Course Beginner to Advance | Tables in HTML | Web Development Course Lecture 8

Coding Shuttle by Anuj Bhaiya
5 Sept 202217:54

Summary

TLDRThis web-development course segment covers HTML tables, teaching how to create and structure them using 'table', 'tr', 'td', and 'th' tags. It explains the use of 'thead', 'tbody', and 'tfoot' for organization, 'caption' for titles, and 'colgroup' with 'col' for column styling. The instructor demonstrates Emmet shortcuts for coding efficiency and emphasizes styling tables with CSS over deprecated HTML attributes. The video also touches on 'rowspan' and 'colspan' for merging cells and encourages learners to practice by replicating a sample table.

Takeaways

  • 🌐 The video is a part of a complete web-development course covering HTML, CSS, and JavaScript from beginner to advanced levels.
  • 📘 The focus of the video is on creating tables in HTML, which are useful for displaying data in a structured format.
  • 🔑 The 'table' tag is fundamental for creating tables, with 'tr' for table rows and 'td' for table data.
  • 📝 The video demonstrates how to code a simple table with HTML, including using Emmet for quicker coding.
  • 🖌️ It's recommended to style tables using CSS rather than deprecated HTML attributes for better practices in modern web development.
  • 🔍 For a deeper understanding of tables, viewers are encouraged to visit MDN for comprehensive information on table elements and styling.
  • 🔑 'th' is used to create table headers, making the text bold and distinct from the rest of the table data.
  • 📊 The 'thead', 'tbody', and 'tfoot' tags are used to define the head, body, and foot of a table, respectively, and are good for organization but not mandatory.
  • 🏷️ The 'caption' tag is used to define the title or topic of the table, which appears at the top.
  • 🎨 'colgroup' and 'col' tags are used to apply styles to entire columns, simplifying the process of styling table columns uniformly.
  • 🔄 'colspan' and 'rowspan' attributes are used when table data needs to span multiple columns or rows, useful for complex tables like timetables.

Q & A

  • What are the main topics covered in the web-development course mentioned in the script?

    -The web-development course covers HTML, CSS, and JavaScript, ranging from beginner to advanced levels.

  • How are tables represented in HTML?

    -In HTML, tables are represented using the 'table' tag, with 'tr' for table rows and 'td' for table data.

  • What is the purpose of the 'tr' and 'td' tags in HTML tables?

    -The 'tr' tag is used to create a table row, while 'td' is used to define individual cells within that row to store data.

  • How can you create a table with three rows and three columns using Emmet in a code editor?

    -You can create a table with three rows and three columns by typing 'table > tr*3 > td*3' and pressing 'enter'.

  • What does the 'thead' tag in HTML represent?

    -The 'thead' tag represents the header part of a table, containing the topmost row or rows of the table.

  • What is the difference between 'td' and 'th' tags in HTML tables?

    -The 'td' tag is used for standard table data cells, while 'th' is used for header cells, which are typically bold and centered by default.

  • How can you style a table using CSS?

    -You can style a table using CSS by defining properties such as border, background color, spacing, and padding for the table and its elements.

  • What does the 'colspan' attribute do in a table?

    -The 'colspan' attribute is used in 'td' or 'th' elements to make a cell span across multiple columns.

  • What does the 'rowspan' attribute do in a table?

    -The 'rowspan' attribute is used in 'td' or 'th' elements to make a cell span across multiple rows.

  • What is the purpose of the 'caption' tag in a table?

    -The 'caption' tag is used to define a title or caption for the table, which is displayed above the table.

  • How can you apply a specific style to an entire column in a table using 'colgroup'?

    -You can apply a specific style to an entire column by defining it within a 'col' element inside 'colgroup' and using the 'span' attribute to specify the number of columns affected.

Outlines

00:00

📚 Introduction to HTML Tables

The video begins with an introduction to the web-development course, focusing on HTML, CSS, and JavaScript. The instructor discusses the creation of tables in HTML, explaining the use of 'table', 'tr', and 'td' tags to structure data. The importance of bookmarking the playlist and subscribing to the channel for daily updates is emphasized. The video demonstrates coding a simple table with rows and data cells, utilizing Emmet for quick coding. The instructor also explains how to collapse code segments for better focus and mentions the use of 'Autosave' and 'Live Server' features in the development environment.

05:03

🖌️ Styling HTML Tables with CSS

This paragraph delves into the styling aspects of HTML tables. The instructor explains the use of 'th' to create table headers and demonstrates how to apply bold formatting. The concept of borders in tables is introduced, with a mention of the deprecated 'border' attribute and the recommended use of CSS for styling. The video shows how to apply a solid border to a table using the 'style' attribute. The instructor also covers the use of 'thead', 'tbody', and 'tfoot' tags to structure table sections and how to apply different styles to them. A resource link for further understanding of table styling is provided.

10:07

🔍 Advanced Table Elements and Attributes

The instructor introduces advanced table elements such as 'caption', 'colgroup', 'col', 'rowspan', and 'colspan'. The 'caption' element is used to define the table's title, while 'colgroup' and 'col' allow for styling entire columns at once. The 'span' attribute is explained as a way to extend styles across multiple columns. The paragraph also covers how to use 'rowspan' and 'colspan' to merge cells across rows and columns, with examples from a sample timetable. The importance of replicating tables for practice is highlighted, and the upcoming mini project on creating a resume website is teased.

15:07

🛠️ Practical Application of Table Elements

The final paragraph focuses on the practical application of table elements. The instructor guides viewers through the process of coding a complex table with merged cells, using 'rowspan' and 'colspan' attributes. The paragraph emphasizes the importance of understanding how to inspect and replicate such tables for better comprehension. The video concludes with an invitation for viewers to practice creating tables and a reminder of the upcoming mini project to build a resume website, which will consolidate the skills learned throughout the course.

Mindmap

Keywords

💡HTML

HTML, or HyperText Markup Language, is the standard markup language for creating web pages and web applications. It is the foundational building block of the internet, defining the structure and layout of web content. In the video, HTML is the main focus as the instructor discusses how to create tables, which are a key element for organizing data on web pages, using HTML tags such as 'table', 'tr', and 'td'.

💡CSS

CSS stands for Cascading Style Sheets, a language used for describing the presentation of a document written in HTML or XML. It provides a way to style and layout web pages, including colors, fonts, and spacing. In the script, CSS is mentioned in the context of styling tables, such as adding borders, backgrounds, and padding, which is crucial for enhancing the visual appeal and usability of web content.

💡JavaScript

JavaScript is a programming language that allows interactive web pages and is an essential part of web development. While not the main focus of the video, JavaScript is part of the trio of technologies, along with HTML and CSS, that are taught in the course. It's used to create dynamic content, handle events, and manipulate the Document Object Model (DOM) of a web page.

💡Tables

In web development, tables are used to display data in a grid-like format, making it easier for users to read and understand information. The video script focuses on teaching how to create and manage tables in HTML, using tags such as 'table', 'tr' for table rows, and 'td' for table data, which are vital for structuring content on web pages.

💡Table Row (tr)

The 'tr' tag in HTML is used to define a row in a table. Each 'tr' element contains one or more 'td' elements that represent individual cells within that row. The script explains how to use 'tr' to create multiple rows in a table, which is essential for organizing data vertically.

💡Table Data (td)

The 'td' tag stands for 'table data' and is used to create individual cells within a table row. In the script, 'td' is used in conjunction with 'tr' to fill in the rows with data, demonstrating how to structure information horizontally across a table.

💡Table Header (th)

The 'th' tag is used to define a header cell in a table, which typically contains bold text to denote column or row headings. The video script explains the use of 'th' to make certain cells stand out as headers, providing a clear distinction between the headers and the data in the table.

💡Autosave

Autosave is a feature commonly found in code editors and integrated development environments (IDEs) that automatically saves changes to a file at regular intervals or after specific actions. In the script, Autosave is mentioned as a convenience feature that ensures the code is saved without manual intervention, allowing the developer to focus on writing code.

💡Live Server

A Live Server is a development server that updates the web page in real-time as you make changes to the code, without the need to manually refresh the browser. The script mentions the Live Server, which is used for testing and previewing web pages during development, running on port 5500 in this context.

💡MDN

MDN stands for Mozilla Developer Network, a platform that provides comprehensive documentation, guides, and resources for web developers. In the script, MDN is recommended as a go-to source for further information on HTML table elements, attributes, and styling, indicating its value as a learning resource.

💡Deprecated Attributes

Deprecated attributes are HTML properties that were once used but are no longer recommended due to newer standards or better alternatives. The script warns against using deprecated attributes for styling tables in HTML5, advocating for CSS as the preferred method for applying styles to web elements.

💡Colspan and Rowspan

The 'colspan' and 'rowspan' attributes in HTML are used to make a table cell ('td' or 'th') span across multiple columns or rows, respectively. The script explains how to use these attributes to create complex table structures where certain data points need to occupy more than one cell, as seen in timetables or categorized lists.

💡Table Sections

In HTML, a table can be logically divided into three main sections: the header ('thead'), the body ('tbody'), and the footer ('tfoot'). The script discusses these sections, explaining that they allow developers to group rows and apply different styles or behaviors to different parts of the table, enhancing the semantic structure of the data.

💡Caption

The 'caption' element in HTML represents the title of the table and is used to provide a summary or description of the table's content. In the script, 'caption' is shown as a way to add a heading above the table, which is important for accessibility and understanding the context of the table.

💡Colgroup and Col

The 'colgroup' and 'col' elements in HTML are used for defining and styling columns within a table. 'colgroup' can contain one or more 'col' elements, and it allows for applying styles to an entire column or a set of columns at once. The script demonstrates how to use 'colgroup' and 'col' to apply a background color to specific columns in a table for stylistic purposes.

Highlights

Introduction to the complete web-development course covering HTML, CSS, and JavaScript from beginner to advanced levels.

Explanation of how to create tables in HTML, a fundamental aspect of structuring data on websites.

Use of 'table', 'tr', and 'td' tags for creating table rows and data cells.

Demonstration of creating a table with headers and items to represent data effectively.

Inclusion of a playlist for easy access and updates on new course content.

Coding a table with the 'table' tag and utilizing Emmet for quick row creation.

Inserting data into table rows with 'td' tags for individual data elements.

Use of 'th' tag to create table headers for emphasis and distinction.

Mention of deprecated attributes and the recommendation to style tables with CSS instead.

Introduction to 'thead', 'tbody', and 'tfoot' tags for organizing table sections.

Explanation of how to use 'colspan' and 'rowspan' attributes for merging cells in tables.

Importance of 'caption', 'colgroup', and 'col' tags for defining table titles and column styles.

Practical example of applying CSS styles to table columns using 'colgroup' and 'col'.

Demonstration of how to apply different styles to table headers and footers.

Discussion on the benefits of using 'thead', 'tbody', and 'tfoot' for assigning different behaviors to table sections.

Recommendation to visit MDN for more detailed information on table elements and styling.

Announcement of an upcoming mini project to create a resume website using the learned concepts.

Transcripts

play00:00

Hey, what's up guys!

play00:00

Welcome to the complete web-development course

play00:02

where we're learning the concepts of HTML, CCS & JavaScript

play00:04

from beginner to advanced level.

play00:06

Today we're going to talk about Tables.

play00:08

Earlier, we learnt how list items work. How can you create lists?

play00:12

Ordered and Unordered.

play00:13

Today we're going to talk about how you can create tables in HTML.

play00:16

And this is our playlist, which should be bookmarked

play00:18

so that its easily accessible & subscribe to the channel

play00:20

and click on the notification Icon because videos are being uploaded daily.

play00:23

And so that you don't miss the notification of any video.

play00:26

Today we'll talk about tables.

play00:28

Tables look something like this.

play00:30

You might have seen in websites and

play00:32

basically, it helps to show one type of data in a format very easily.

play00:35

So, you can have headers.

play00:37

then there could be some items in the table.

play00:39

Right!

play00:39

Just like this.

play00:40

Here, you might write some numbers.

play00:42

Suppose, you wrote Title over here.

play00:44

And here you wrote a description.

play00:46

So, if you want to show tables in this way in your website

play00:49

then for that we use 'table' tag.

play00:51

We can use two tags in it - 'tr' and 'td'.

play00:54

'tr' basically means table row.

play00:56

'td' means table data.

play00:58

So, we're going to learn how all of this works.

play00:59

Here, you might see that I've created a table.

play01:01

This is our 'table' tag.

play01:02

I've nested a table row in it due to which a row will be created in the table.

play01:06

So, suppose if I want to say that this is our row, the upper row.

play01:10

If I want to create this row,

play01:12

I'll make a table row in the table for that.

play01:14

And then if I need to create the lower row, then I'll make another 'tr' for it.

play01:18

And if I need to create another row below it, then I'll make another 'tr' for it.

play01:21

So, in this way you'll make different 'tr'(s) for the table that you need to make

play01:24

and if you want to store data in them, for example,

play01:26

if I want to store a data - Serial No.

play01:27

then I'll make a 'td' for it, then I'll create another 'td' for Title.

play01:30

and then another 'td' for description.

play01:32

Let's try coding it.

play01:33

In the previous video, we learnt how to make Unordered & Ordered list.

play01:38

If you want you can minimize this.

play01:39

To minimize, you've to come to the side bar where numbers are written

play01:44

with which you get to know which line are you coding in.

play01:47

You might be able to see an Icon beside it, with which you can collapse any segment.

play01:51

So, I'll collapse this entire 'ol'

play01:53

so that it doesn't distracts us again and again.

play01:55

So, we'll collapse it.

play01:56

As you can see, the entire 'ol' has been collapsed.

play02:00

This is the benefit of an Editor.

play02:01

You can expand it as well and then collapse it again.

play02:04

Below this, we're going to write our table, so

play02:06

we'll create a table - 'table' and we can use Emmet in it.

play02:09

After table, we'll write 'greater than (>)' and we'll include 'tr' in it.

play02:14

Suppose, I need 3 rows in it & 'tr*3'

play02:17

and then press 'enter'

play02:18

So, here 3 'tr'(s) have been created in a table.

play02:21

Now, I need to insert data into these 'tr'(s).

play02:23

Suppose, I insert data in the 1st row.

play02:25

Suppose, I keep three 'td'(s) in it, so

play02:29

'td*3'

play02:31

Hit 'enter'

play02:31

So, here I've three data elements in a row.

play02:35

So, we'll read it in this way.

play02:36

Here, we've a table

play02:38

in which I've kept 3 data elements in its first row which means

play02:42

in this row, there'll be three columns

play02:44

in which these values would be added.

play02:45

Suppose, I want to keep the values in it.

play02:49

So, in this way I've these values.

play02:51

And below them I'll mention subjects,

play02:53

which subject I had.

play02:54

So, I'll copy this.

play02:56

And we'll paste it here.

play02:57

Suppose the subject was Mathematics.

play03:00

In marks, let's say 98.

play03:03

And in passed we'll write 'Yes'.

play03:05

And then, I'll copy the same thing in the lower row.

play03:08

So, I'll copy and paste the same thing in the 3rd row.

play03:11

And supposedly, let's write here English.

play03:14

In Marks, let's say 12.

play03:17

And in passed let's write 'Fail'.

play03:19

So, 'No'.

play03:20

You don't need to save it because we've already switched on the 'Autosave'.

play03:23

Here, you can see 'Autosave' is switched On.

play03:25

And along with that we've also switched on the Live Server.

play03:27

So, its working on port 5500.

play03:29

By the way, to run this Live Server, you need to install the extension of this Live Server.

play03:33

After that, you need to run this live server below.

play03:36

After that, when you'll open your browser, you'll find your website running on this port.

play03:40

As you can see here, our table has been created here.

play03:43

In this table, these three things are there in the top row.

play03:46

And the middle row consists of another three things

play03:48

and the bottom row consists of another three things.

play03:50

So, its this easy to create a row.

play03:52

If we want to know more details about this table then we'll further search it

play03:55

on MDN.

play03:56

So, we'll search 'table mdn'.

play03:58

Here, we can read entirely about the table elements.

play04:01

What are the things included in the table elements?

play04:02

What attributes are included?

play04:04

How should we do the styling of the table?

play04:05

So, there used to be some attributes for the styling of the table

play04:08

in HTML 4

play04:09

In HTML 5, all of those attributes have been removed.

play04:12

You're recommended to style the table with the help of CSS.

play04:15

So, if you want to to add border, background even

play04:18

if you want to give spacing between the cells

play04:20

and padding as well. You should do that with the help of CSS

play04:22

and not with the deprecated attributes.

play04:24

I had told you about Deprecated attributes.

play04:26

These are such attributes whose support has been removed

play04:28

and you shouldn't use them in your modern websites

play04:31

because you may lose their support anytime soon.

play04:33

If we move further in this documentation, then we can read more things

play04:37

that how you create a table and define table data with the help of 'td'.

play04:42

You can use 'th' instead of 'td'

play04:44

and so that cell would basically become your header

play04:46

Means it'll get a little bold and it'll look differently.

play04:49

It'll standout

play04:50

in comparison to the rest of the elements, so

play04:52

you can convert those cells into headers which you need to focus more on.

play04:56

For example, here, they've written - 'Animals'

play04:58

So, the 'Animals' part will seem highlighted and bold.

play05:03

You can see here that 'Animals' has become bold.

play05:05

And then there's Hippopotamus, Horse

play05:07

So all these are created under 'th'

play05:09

The stallion and mare would have been crested under 'td'

play05:14

whichever word is in bold, is basically crested under 'th'

play05:16

Let's see how it works.

play05:18

So, in my website I want all my elements in the upper row to be Headers.

play05:23

All of them should be in bold.

play05:25

So, for this, I need to come to the code and click on File Explorer.

play05:29

And then all these elements should be written under 'th' instead of 'td'

play05:33

So, I'll copy 'th'

play05:35

and then each 'td' will be replaced by 'th'

play05:41

Let's try running it.

play05:42

So, you can see Subject, Marks and Passed are now written in bold.

play05:45

Which means these are our table Headers.

play05:47

Apart from this, you might have noticed another thing that

play05:49

there are borders in their table as well.

play05:52

You can see that this line is visible.

play05:54

But there isn't any line in our table.

play05:57

So, by default borders don't appear in your table, if you want to show the borders

play06:00

for that you can use a deprecated attribute which is

play06:03

'border'

play06:04

So, you'll write ' border ="" '

play06:06

and if you don't write anything here, it'll still work

play06:08

and you can see that an ugly border has appeared.

play06:11

So, the outer border belongs to the table.

play06:14

And then the inner borders actually belongs to the table data.

play06:18

All the 'td' elements contain borders in them.

play06:21

That is why its looking like this.

play06:23

If you want to achieve this type of styling,

play06:25

where you can see this single line border

play06:27

so, for that we'll be using CSS

play06:30

You can use a style attribute here.

play06:33

style attribute is a global attribute

play06:34

In which you can write 'border' and we can define it as 'solid'

play06:39

and if we run it here, then our table is in a solid border

play06:43

But, if you notice borders appeared only above table

play06:46

Actually, we want borders above table headers and table data as well

play06:51

So, for that I need to define that border separately.

play06:53

And then I need to convert collapsed into 'true'

play06:55

So, we'll be talking about CSS.

play06:58

I don't want to go deeply into CSS because we haven't learnt about CCS until now

play07:02

So, for now let's assume that

play07:04

here, its not 'style' so, we'll remove it.

play07:08

and like earlier there was 'border', let's keep it that way for now

play07:13

to understand it properly.

play07:13

I don't want to confuse you by showing the syntax of CSS.

play07:17

We'll deal with that properly while we're studying CSS.

play07:20

But, if you want to learn on your own how the table is styled

play07:23

then you can visit this link - Styling Tables

play07:25

where they've clearly mentioned how a table is styled

play07:28

By default, your table looks something like this.

play07:31

In which you need to work through styling the table.

play07:32

So, you can refer it with the style sheet here and

play07:35

then you can put properties like this in CSS

play07:38

so that your table looks in a stylish format.

play07:41

So, I'll give the link in the description below

play07:44

where you can visit and read that how does the styling works

play07:47

Now, let's move forward without focusing much on styling.

play07:50

So, you can see that you can make funky tables like this.

play07:54

Now, our table is looking like this, there isn't much of styling in it.

play07:57

But, there are more concepts in a table, let's understand them.

play08:00

There are more tags in a table.

play08:02

You can see the header over here, this section is totally different.

play08:06

there is a body part in the middle which contains rows of the table

play08:09

and then below they have made a footer.

play08:11

So, in this way we also need to make a table.

play08:13

We've 3 tags, one is 'thead' which contains the head of the table.

play08:17

Another is the 'tbody' which contains this entire body.

play08:20

And lastly 'tfoot' which contains the footing of the table.

play08:23

We've written all of it here.

play08:24

Let's understand it one by one.

play08:26

So, there are 3 tags, one is the 'thead'

play08:28

another is 'tbody' and lastly 'tfoot'.

play08:30

Here, we've written 'thead' element defines a set of rows

play08:33

defining the head of the columns of the table.

play08:36

'tbody' - The 'tbody' element encapsulates a set of table rows

play08:39

indicating that they comprise the body of the table.

play08:42

and then lastly there is 'tfoot'.

play08:44

'tfoot' element defines a set of rows summarizing the columns

play08:47

of the table.

play08:48

So, let's deal with them one by one in the code.

play08:50

So, If I put the upper row in the 'thead'

play08:54

it'll become out 'thead', so 'thead'

play08:56

press enter and then what I need to do is

play08:58

select this entire part and press 'Command X + command B'

play09:02

with this it'll be transferred into our head section.

play09:04

the part after this, supposedly this one

play09:07

I want it to be in 'tbody', so for that

play09:09

I'll write 'tbody' and then press 'enter'

play09:11

and then I transfer the middle part including the two rows into 'tbody'.

play09:16

And then lastly, we can make a footer.

play09:18

Supposedly, like this.

play09:20

'tfoot'

play09:22

and suppose we'll make a row in it.

play09:24

'tr'

play09:25

and I'll make two 'td'(s) in it.

play09:30

In the first 'td' we'll write Passed.

play09:33

And in the second one we'll write 'Yes'.

play09:35

Let's make put them in 'th' instead of 'td'

play09:38

So, I pressed it by mistake.

play09:39

All of the 'td'(s) will be converted into 'th'.

play09:45

Alright!

play09:46

Let's see how it looks.

play09:48

So, you can see our table looks something like this.

play09:50

Here, the upper part comes under 'thead'

play09:53

Both of this part comes under body

play09:56

And the last part comes under footer.

play09:59

Here, I would like to point one more thing that

play10:01

You don't need to write 'thead', 'tbody', 'tfoot' in your code.

play10:07

Means if you omit and write it simply

play10:10

if you don't add 'thead', 'thead' and 'tfoot'

play10:18

If you kept it simple like this

play10:21

it'll still work.

play10:22

Alright!

play10:22

If I comment out them for now

play10:24

to comment them out, we've to click on 'Command /'

play10:27

du to which our browser won't read the comment part.

play10:30

So, you can see I've a simple table which contains multiple rows

play10:34

in which some have header and some have data

play10:36

this is exactly looking similar.

play10:38

Its looking exactly similar.

play10:40

Then what is the difference?

play10:41

Difference is just that you can use them separately in a proper way.

play10:45

You can assign different behaviors to the sections in your table

play10:48

So, this is just a good practice, but not a required practice.

play10:51

Right!

play10:52

So, lets set it again by command.

play10:54

Let's make everything like before.

play10:57

So, basically this is just a recommended practice but not a required one.

play11:02

Your browser will still work.

play11:03

Your code will still work even though you don't write these 3 things

play11:06

So, this was very simple.

play11:08

After that, let's talk about some more attributes.

play11:10

So, next attribute is going to be 'caption', 'colgroup' and 'col'

play11:14

So, 'caption' basically helps you to define the topic of the table

play11:19

The 'caption' element specifies the caption or the title of the table.

play11:22

So, its helpful for that.

play11:24

And then, next we've 'colgroup'.

play11:26

With the help of 'colgroup' you can assign different styles to different columns

play11:30

So, if you want you can give a particular styling to an entire column

play11:33

otherwise if you didn't have 'colgroup', then you might have to

play11:36

visit each row and assign a different styling to a particular column.

play11:40

So, with the help of 'colgroup', you don't need to do it.

play11:42

You just define it in one place that this column should be styled in this way.

play11:46

And then, the entire column will follow one particular styling.

play11:50

Alright!

play11:50

So, we use 'co' with 'colgroup'.

play11:52

Because you can put groups of different columns in 'colgroup'

play11:56

So, we've 'colgroup' and 'col'.

play11:58

The 'col' element defines the column within a table

play12:00

and is used for defining common semantics on all common cells.

play12:03

It is generally found within a 'colgroup' element.

play12:06

So, we use 'col' in 'colgroup' element.

play12:08

Let's deal with the code.

play12:09

First of all, let's see how 'caption' works.

play12:12

Let's make 'caption' in the table before the header.

play12:16

'caption'

play12:17

And we can define 'My Marksheet' in it.

play12:22

So, this caption will be visible at the top.

play12:23

Here, as you can see - Mt Marksheet.

play12:25

It is visible at the top.

play12:26

So, basically this is the title of this table.

play12:29

Then, we can define a column group. Right!

play12:32

So, 'colgroup'

play12:35

and we can define different columns in this 'colgroup'

play12:38

Suppose, this will be my first column.

play12:39

So, column is basically an empty tag in which you don't need to mention closing tag.

play12:44

Its an empty element.

play12:45

And we can define our span in it.

play12:47

So, in span attribute we can define the no. of columns we need to cover

play12:52

with the styling, Right!

play12:53

So, in this 'col' element how many columns are we going to style?

play12:57

Will we style one column, two or three columns?

play13:00

So, by default it styles one single column.

play13:03

If I don't write this here and suppose

play13:05

let me add a styling here, so

play13:06

'style'

play13:07

Let's give each one a background color.

play13:10

Let's set the background color to blue.

play13:12

So, this is a part of CSS with which we can give the styling.

play13:15

So, what I did was, I assigned a blue color background to one column

play13:18

Let's try running it.

play13:20

So, as you can see here.

play13:21

One column has been colored blue

play13:23

so with this entire column is colored now.

play13:26

If I want to toss this styling to the other 2 columns

play13:30

in both Subject & Marks

play13:32

this styling should be there.

play13:33

So, for that I'll use 'span' attribute'.

play13:35

'span ="2" '

play13:37

due to which this styling will span in both of the columns.

play13:43

Alright!

play13:43

So, as you can see these two columns contain this style.

play13:46

If I write here 'span =3'

play13:49

then this style would toss over 3 columns.

play13:52

You can make different 'col'(s) because this is a 'colgroup'

play13:55

So, if you want you can make it for 2 columns

play14:00

and you can define one singly below

play14:03

which will move on to the next one, right!

play14:04

So, we don't need to define 'span' over here.

play14:06

And let's keep its color red.

play14:08

Alright!

play14:10

So, we'll run it and as you can see here

play14:12

2 columns have blue background and last column has red.

play14:15

Alright!

play14:16

So, the 'colgroup' works in this way.

play14:17

You can define different columns in it.

play14:20

With its help you're able to define how you want to style your columns

play14:24

And with the help of 'span' you define the number of columns to be styled.

play14:28

You can put number of columns in a 'colgroup', as you desire.

play14:32

Apart from this, you can assign different style to your heading.

play14:35

Suppose, we want the background color of the heading to be yellow

play14:38

With this, entire head would be colored yellow.

play14:41

Right!

play14:41

So, you might have understood how useful 'head' is.

play14:44

With this, our entire 'head' was colored in one step.

play14:46

And if you want you can assign different color to your footer.

play14:49

So, let's use the color - 'style "background color = thistle''

play14:54

and you can see the footer has been colored differently

play14:57

If you aren't able to understand how I'm writing background color in style, then

play15:01

basically it is CSS, again

play15:03

when we'll learn CSS, then it's going to be very easy for you.

play15:05

We use it a lot in it.

play15:07

This is basically in-line CSS, but don't be tensed about it now

play15:10

with its help I'm basically telling you about how you can

play15:13

style everything together. In your header, different columns

play15:18

and in footers as well.

play15:19

So, what is the benefit of making them?

play15:21

Apart from these attributes, we've 2 more attributes.

play15:24

Which I haven't mentioned in my notes because we don't use them much.

play15:28

they are basically - 'colspan' & 'rowspan'.

play15:31

'colspan' tells us when a table data takes the space of 2 columns

play15:35

So, there you can write 'colspan2 or 3' as you wish.

play15:38

And then 'rowspan' is used when you want to give table data the space of 2 or 3 rows

play15:43

So, you can use it in 'td'.

play15:45

Alright!

play15:46

Or you can also use it in 'th'

play15:47

So, this is our 'td' & when we'll use it then how will it look?

play15:50

Suppose, I want this 'Passed' to take the space of 2 columns below.

play15:55

and 'Yes' should shift to the right.

play15:57

So, for this I need to come back to the code

play15:59

and in the 'th' of 'Passed', I'll write

play16:03

colspan ="2"

play16:05

and you'll see here that 'Passed' shifted itself by taking up the space of 2 columns

play16:09

and 'Yes' had shifted to the right.

play16:10

So, here it's making more sense, but it might not always make sense.

play16:14

You might have seen this type of tables in timetables, colleges or schools

play16:18

Where this type of table is made

play16:21

where some of the data takes the space of 2 or even 4 columns

play16:27

they even takes the space of 2 or 4 rows as well

play16:28

As you can see here, this data 'Terrestrial Planets'

play16:32

Actually it has taken the space of 4 rows & 2 columns.

play16:35

Similarly, 'Gas giants' has taken up the space of 1 column and 2 rows.

play16:39

'Ice giants' took up the space of 1 column & 2 rows as well.

play16:42

So, they are created in this way.

play16:43

If we inspect this then you can easily read it.

play16:46

But, before inspecting I would highly recommend you to try replicating this table

play16:53

and let's see how you're able to do it?

play16:56

It'll be easy for you, basically what you've to do is

play16:58

you need to move ahead row by row, right!

play16:59

In the table, first we'll write the first 'tr'

play17:02

after that we'll write the 'tr' below it as well.

play17:04

In the lower 'tr', you'll right 'Terrestrial Planets' for the first time and

play17:06

in it you'll write that its 'rowspan' is four and 'colspan' is two.

play17:10

After that you'll move forward after writing - 'Mercury' and so on......

play17:12

But, in the row below it, you won't write 'Terrestrial Planet' again.

play17:16

You'll start writing from 'Venus' & then move forward in it.

play17:18

Are you able to understand?

play17:19

If we inspect it once

play17:22

then you'll understand it more clearly over here

play17:24

Here, you can see we've 'tbody' then 'tr'

play17:27

Here, the column span is two & rowspan is four

play17:30

and it's working in this way.

play17:32

then if we check the row below it,

play17:34

it starts to fill with 'Venus'.

play17:37

the next row starts to fill from 'Earth'.

play17:40

So, try replicating this table in your website.

play17:44

In the upcoming video, we'll be making a mini project.

play17:46

With the help of all the things that we've learnt,

play17:48

we'll try to make a mini project.

play17:50

Basically, we'll try to make a resume website.

play17:52

So, we'll deal with it in the next video.

Rate This

5.0 / 5 (0 votes)

相关标签
Web DevelopmentHTML TablesCSS StylingJavaScriptWeb DesignBeginner GuideAdvanced ConceptsTable HeadersData PresentationOnline Tutorial
您是否需要英文摘要?