w3resource

HTML5: How to define a table caption?

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>How to define a table caption</title>
</head>
<body>
<table border="1">  
<caption>First column holds Student code and second column holds percentage of marks obtained by the student</caption>  
<tr>   
<th>Student code </th>  
<th>% of marks </th>  
</tr>  
<tr>   
<td>S001</td>  
<td>85</td>  
</tr>  
<tr>   
<td>S002</td>  
<td>86</td>  
</tr>  
<tr>   
<td>S003</td>  
<td>72</td>  
</tr>  
<tr>   
<td>S004</td>  
<td>89</td>  
</tr>  
</table
</body>
</html>

Live Demo :

See the Pen caption-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.

HTML-CSS: Tips of the Day

How to "crop" a rectangular image into a square with CSS?

HTML:

<div class="thumb1">
<a href="#">Link</a>
</div> 

CSS:

.thumb1 { 
  background: url(blah.jpg) 50% 50% no-repeat; /* 50% 50% centers image in div */
  width: 250px;
  height: 250px;
}

.thumb1 a {
  display: block;
  width: 250px;
  height: 250px;
}
.thumb1 a:hover { YOUR HOVER STYLES HERE } 

Note this could also be modified to be responsive, for example % widths and heights etc.

Ref: https://bit.ly/3PVH5Vt

 





We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook