I am learning about classes right now in PHP and their examples are like..
class table { //makes a table
    private $tag ;
    function Begin($border=0, $align="center", $width='100%', $cellpadding=2, 
        $cellspacing=2, $class='', $id='', $bgcolor='', $style='') {
        $this->tag = '<table ' ;
        if ($align)              $this->tag .= 'align="' . $align . '" ' ;
        if ($width)              $this->tag .= 'width="' . $width . '" ' ;
        if ($border > 0)         $this->tag .= 'border="' . $border . '" ' ;
        if ($cellpadding > 0)     $this->tag .= 'cellpadding="' . $cellpadding . '" ' ;
        if ($cellspacing > 0)     $this->tag .= 'cellspacing="' . $cellspacing . '" ' ;
        if ($class)              $this->tag .= 'class="' . $class . '" ' ;
        if ($id)                  $this->tag .= 'id="' . $id . '" ' ;
        if ($bgcolor)              $this->tag .= 'bgcolor="' . $bgcolor . '" ' ;
        if ($style)              $this->tag .= 'style="' . $style . '" ' ;
        $this->tag .= ">" ;
        return $this->tag ;
    }
Then you just instantiate it and make a table by 
$table =new table;
$table->$table($border=2, $align='center', etc);
Should I be coding like this where html, css are in classes? 
i feel making tables and forms this way is more confusing then actually just typing . Should I only put like validation, getting data from db, and the logic stuff in classes?
What should I use classes for and not?