/    Sign up×
Community /Pin to ProfileBookmark

convert tables to CSS

I have used tables on my website to lay out the images and some css for font etc. I have read often on webdeveloper that its not best practice to use tables for doing this and so I would like to convert my tables to css. Could someone please get me started?

[url]http://www.gordonengraving.co.uk[/url]

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@KDLASep 19.2005 — Give this a try:

http://www.w3schools.com/css/default.asp

Your site is pretty basic. It shouldn't be that hard to convert to CSS.

The hardest part is recovering from "box layout syndrome" and getting used to the design freedom css allows.

KDLA
Copy linkTweet thisAlerts:
@NogDogSep 19.2005 — I might approach it something like this:
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
<title>Page title</title>
<link type="text/css" rel="stylesheet" href="http://www.gordonengraving.co.uk/style.css">
<style type="text/css">
<!--
#contact {
margin: 1em 0;
padding: 0.5em 0 1em 0;
border-top: solid 2px silver;
border-bottom: solid 2px silver;
}
.address {
float: left;
margin-right: 3em;
}
.clear {
margin: 0;
padding: 0;
font-size: 1px;
line-height: 1px;
clear: both;
height: 1px;
}
#contact h5 {
margin-top: 0;
}
-->
</style>
</head>
<body>
<p>...start of page...</p>
<div id="contact">
<h4>Contact Details</h4>
<div class="address">
<h5>Address:</h5>
<p>Gordon Engraving Ltd<br>
Roper Road, Roper Close<br>
CANTERBURY<br>
Kent, CT2 7EP<br>
U.K.</p>
</div>
<div class="address">
<h5>Electronic:</h5>
<p>Tel: 01227 766229</p>
<p>Fax: 01227 762264</p>
<p>Email:
<a href="mailto:[email protected]">[email protected]</a>
</p>
</div>
<div class="clear"></div>
</div> <!-- contact -->
<p>...rest of page...</p>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@chesswillauthorSep 19.2005 — So the contact details are floating on the left.

How do you determine the positioning of the right hand paragraph or images for example?
Copy linkTweet thisAlerts:
@FangSep 19.2005 — More fun with an address:
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;address&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;style type="text/css"&gt;
&lt;!--
dl {
margin:auto;
overflow: auto;width:80%;
border-top:solid 2px #ccc;
border-bottom:solid 2px #ccc;
padding:1em 0;
}
dt {font-weight:bold;}
dd {float:left;}
--&gt;
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;dl&gt;
&lt;dt&gt;Contact Details&lt;/dt&gt;
&lt;dd&gt;
&lt;address&gt;Gordon Engraving Ltd&lt;br&gt;Roper Road, Roper Close&lt;br&gt;CANTERBURY&lt;br&gt;Kent, CT2 7EP&lt;br&gt;U.K.&lt;/address&gt;
&lt;/dd&gt;
&lt;dd&gt;Tel: 01227 766229&lt;br&gt;Fax:01227 762264&lt;br&gt;Email: &lt;a href="mailto:[email protected]"&gt;[email protected]&lt;/a&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;more content ...&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@NogDogSep 19.2005 — So the contact details are floating on the left.

How do you determine the positioning of the right hand paragraph or images for example?[/QUOTE]

In my example I used the margin-right value of the floated elements to separate one from the next. You could assigned fixed widths to those elements if you wanted more control on their exact locations, and/or you could also adjust the margin-left (and top or bottom) for further positioning tweaks.
Copy linkTweet thisAlerts:
@JonaSep 19.2005 — [font=Trebuchet MS]I think there is some explanation necessary, but I haven’t the time at this very moment. However, I did put the following .zip file together so you can see how it&#8217;s done in CSS. At least, how I would do it. Notice the appropriate use of HTML elements such as ADDRESS, UL, and DL.[/font]

[upl-file uuid=67613c56-0a07-4ef5-b454-5e5cf1eeecdc size=8kB]gordonengraving.zip[/upl-file]
×

Success!

Help @chesswill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...