Learning HTML - Day 5

 Today is 29th January 2021 and it is my fourth day to learn HTML 🙋

Day 4 - Time 8.00 pm - 9.15 pm

Day 1      Day 2

Decorating a Table - 

  • The HTML class attribute specifies one or more class names for an element
  • Classes are used by CSS and JavaScript to select and access specific elements
  • The class attribute can be used on any HTML element
  • The class name is case sensitive
  • Different HTML elements can point to the same class name
  • JavaScript can access elements with a specific class name with the getElementsByClassName() method

 -

Example 1 - Without style attribute
<html>
<head>
<title>My web page</title>
</head>
<body>
<table border="2px" bordercolor="blue">
<caption>Example</caption>
<tr>
<th>Name</th>
<th>Country</th>
<th>Profession</th>
</tr>
<tr>
<td>Sachin Tendulkar</td>
<td>India</td>
<td>Cricket</td>
</tr>
<tr>
<td>Roger Federer</td>
<td>Switzerland</td>
<td>Lawn Tennis</td>
</tr>
<tr>
<td>Lionel Messi</td>
<td>Argentina</td>
<td>Football</td>
</tr>
<tr>
<td>Sania Nehwal</td>
<td>India</td>
<td>Badminton</td>
</tr>
</body>
</html>

Using style attribute - 

Code - 
<html>
<head>
<title>My web page</title>
<style>
table, th, td{
border:2px solid black;
}
</style>
</head>
<body>
<table class="table">
<caption>Example</caption>
<tr>
<th>Name</th>
<th>Country</th>
<th>Profession</th>
</tr>
<tr>
<td>Sachin Tendulkar</td>
<td>India</td>
<td>Cricket</td>
</tr>
<tr>
<td>Roger Federer</td>
<td>Switzerland</td>
<td>Lawn Tennis</td>
</tr>
<tr>
<td>Lionel Messi</td>
<td>Argentina</td>
<td>Football</td>
</tr>
<tr>
<td>Sania Nehwal</td>
<td>India</td>
<td>Badminton</td>
</tr>
</body>
</html>

Notice that the table in the examples above have double borders. This is because both the table and the <th> and <td> elements have separate borders.

To remove double borders use border-collapse:collapse


Code - 

<html>

<head>

<title>My web page</title>

<style>

table, th, td{

border:2px solid black;

border-collapse: collapse;

}

</style>

</head>

<body>

<table class="table">

<caption>Example</caption>

<tr>

<th>Name</th>

<th>Country</th>

<th>Profession</th>

</tr>

<tr>

<td>Sachin Tendulkar</td>

<td>India</td>

<td>Cricket</td>

</tr>

<tr>

<td>Roger Federer</td>

<td>Switzerland</td>

<td>Lawn Tennis</td>

</tr>

<tr>

<td>Lionel Messi</td>

<td>Argentina</td>

<td>Football</td>

</tr>

<tr>

<td>Sania Nehwal</td>

<td>India</td>

<td>Badminton</td>

</tr>

</body>

</html>

Stands for "Cascading Style Sheet." Cascading style sheets are used to format the layout of Web pages. They can be used to define text styles, table sizes, and other aspects of Web pages that previously could only be defined in a page's HTML.

Border for only table - 

Output - 

Code - 

<html>

<head>

<title>My web page</title>

<style>

table{

border:2px solid red;

border-collapse: collapse;}


</style>

</head>

<body>

<table class="table">

<caption>Example</caption>

<tr>

<th>Name</th>

<th>Country</th>

<th>Profession</th>

</tr>

<tr>

<td>Sachin Tendulkar</td>

<td>India</td>

<td>Cricket</td>

</tr>

</body>

</html>


Changing background color of table and text color - 

Code - 

<html>

<head>

<title>My web page</title>

<style>

table{

border:2px solid red;

border-collapse: collapse;

background-color: black;

color:yellow;}


</style>

</head>

<body>

<table class="table">

<caption>Example</caption>

<tr>

<th>Name</th>

<th>Country</th>

<th>Profession</th>

</tr>

<tr>

<td>Sachin Tendulkar</td>

<td>India</td>

<td>Cricket</td>

</tr>

</body>

</html>


The inherit keyword specifies that a property should inherit its value from its parent element. The inherit keyword can be used for any CSS property, and on any HTML element.


  • <header> - Defines a header for a document or a section
  • <nav> - Defines a set of navigation links
  • <section> - Defines a section in a document
  • <article> - Defines an independent, self-contained content
  • <aside> - Defines content aside from the content (like a sidebar)
  • <footer> - Defines a footer for a document or a section
  • <details> - Defines additional details that the user can open and close on demand
  • <summary> - Defines a heading for the <details> element
#Semantics to study in detail

Let me try to code it in html - 
<html>
<head>
<title>My Web Page</title>
<style>
table, td {
border:2px solid blue;
border-collapse:collapse;
text-align:center;
height:50px;
Width:500px;}
</style>
</head>
<body>
<table>
<tr>
<td colspan="2">Header</td>
</tr>
<tr>
<td colspan="2">Navigational Tabs</td>
</tr>
<tr>
<td>Section</td>
<td rowspan="2">Aside</td>
</tr>
<tr>
<td>Article</td>
</tr>
<tr>
<td colspan="2">Footer</td>
</tr>
</table>
</body>
</html>













Comments

Popular posts from this blog

Learning HTML - Day 6

Jquery