What is the difference between HTML attributes and CSS properties?

HTML Attributes and Equivalent CSS Properties

HTML Attribute Equivalent CSS Property Description
align text-align Specifies the alignment of text or other elements within their container.
bgcolor background-color Sets the background color of an element.
border border Sets the border properties of an element.
height height Sets the height of an element.
width width Sets the width of an element.
cellpadding padding Sets the padding within the cells of a table.
cellspacing border-spacing Sets the spacing between cells in a table.


HTML Attributes vs CSS Properties

HTML table with attributes
HTML Attributes
Row 1, Cell 1 Row 1, Cell 2
Row 2, Cell 1 Row 2, Cell 2

   
  marquee {
  	color: red;
  }
  
  <!-- HTML table with attributes -->
  <marquee>HTML table with attributes</marquee>
  <table width="100%" border="1" cellpadding="0" cellspacing="0"> 
    <tr align="center" bgcolor="pink"> 
      <th colspan="2">HTML Attributes</th> 
    </tr> 
    <tr  align="center"> 
      <td>Row 1, Cell 1</td> 
      <td>Row 1, Cell 2</td> 
    </tr> 
    <tr  align="center"> 
      <td>Row 2, Cell 1</td> 
      <td>Row 2, Cell 2</td> 
    </tr>
  </table>
  
  

HTML table with CSS properties
CSS Properties
Row 1, Cell 1 Row 1, Cell 2
Row 2, Cell 1 Row 2, Cell 2

  
  /* CSS for styling  */ 
  .styled-table { 
    border-collapse: collapse; 
    width: 100%; 
  } 
  .styled-table th, .styled-table td { 
    border: 1px solid #ddd; 
    padding: 0px; 
    text-align: center; 
  } 
  .styled-table th { 
    background-color: rgb(203, 195, 227); 
  }
  
  <!-- HTML table with CSS properties -->
  <marquee style="color:purple;">HTML table with CSS properties</marquee>
  <table class="styled-table"> 
    <tr>
	<th colspan="2">CSS Properties</th> 
    </tr> 
    <tr> 
      	<td>Row 1, Cell 1</td> 
      	<td>Row 1, Cell 2</td> 
    </tr> 
    <tr> 
      	<td>Row 2, Cell 1</td> 
      	<td>Row 2, Cell 2</td> 
    </tr> 
  </table>
  
  

See also


Comments

Popular posts from this blog

Neat-Flappy Bird (Second Model)

Exploring Memory Components: A Metaphorical Journey

The Evolution of Programming Language Syntax