Solved

html for columns and background color

Posted on 2013-01-07
4
384 Views
Last Modified: 2013-01-16
what would be the html tag(s) to create a columned document with each column having a different color background?  The columns are not even in width with the first column being about 2/3 and the second column being 1/3.  Please give an example of how it would be used for inclusion in MS Access.

Also, what tags would be used to set the background colors and where do they appear in the html sequence?
0
Comment
Question by:uad
4 Comments
 
LVL 14

Assisted Solution

by:shahzoor
shahzoor earned 150 total points
ID: 38751110
<table border="0" width="69%">
	<tr>
		<td width="169" bgcolor="#0000FF">&nbsp;</td>
		<td bgcolor="#008000">&nbsp;</td>
		<td width="274" bgcolor="#FF0000">&nbsp;</td>
	</tr>
</table>

Open in new window


 bgcolor="#0000FF" indicates the background color
td width="169" indicates the size of column
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 350 total points
ID: 38751142
A basic table can look something like below.  The tr tag represents a row and each td is a column.  

<table width="400">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

Open in new window


What you want to do is add your data to each column, repeat the rows, and give each column a class you can style with whatever color you want.  You can add column widths or padding to the table cells through your css styles.  As far as width, you can set that too or if left alone, the table widths will default to the same or width of the widest column without the entire table going wider then your specified.

I would take this in steps. First play with tables using hard coded fake data.  http://www.w3schools.com/html/html_tables.asp

Next play with adding classes to your tables and using css http://www.w3schools.com/css/default.asp

Next, you just need to use a server side language of your choice asp/php/? to talk with your database and generate thml.  If you have 20 rows of data in your database, the below code would produce 21 table rows including the header.
A working sample would be below.

<style>
.col_1 {background-color:red;}
.col_2 {background-color:blue;}
.col_3 {background-color:green;}
</style>

<table width="400">
  <tr>
    <td class="col_1">heading1</td>
    <td class="col_2">heading2</td>
    <td class="col_3">heading3</td>

  </tr>
<%
' loop through your data
do until rs.eof
%>
  <tr>
    <td class="col_1"><%=rs("data1")%></td>
    <td class="col_2"><%=rs("data2")%></td>
    <td class="col_3"><%=rs("data3")%></td>

  </tr>
<%
rs.movenext
loop
%>
</table>

Open in new window

working sample
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38752032
You can use colgroup to target columns, so you don't need a lot of detailed CSS with id or class specifications.  This article covers the column options you can use.


Cd&
0
 

Author Comment

by:uad
ID: 38756055
I am testing the various ways presented and will need a few days to fully see which works best in Access

Question based on the above - does bgcolor (e.g. #CCFFCC) for a specific column remain until bgcolor is resent to say to another color (e.g. #FFFFFF)?  Also, if two columns have different colors, does the bgcolor need to be repeated for each row tag?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now