Cant use <br> or <p> to force new line after table

Associate
Joined
13 Jan 2007
Posts
2,424
Location
Belfast,Northern Ireland
Basically have this problem on two of my asp pages. Both have tables and after them I want to force a line break before i insert my home page link. However this isn't working and I cant see why, I thought I perhaps hadn't closed a set of tags but looks like i've closed everything in both to me! Can anyone help?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>index.html</title>
<link rel="stylesheet" type="text/css" media="screen" href="P7.css" />
</head>

<body>

<%rating = Request.Form("rating")%>
<%parking = Request.Form("parking")%>
<%swimmingPool = Request.Form("swimmingPool")%>
<%bar = Request.Form("bar")%>

<%  
'set up a connection to the database
dbname = "db/Scotland.accdb"
connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" 
connStr = connStr & Server.MapPath(dbname)

'create a connection object
Set connect = Server.CreateObject("ADODB.Connection")

'create a record set object in which the results of the query will be stored
Set results = Server.CreateObject("ADODB.Recordset") 

connect.Open(connStr)
'build an SQL statement
sql = "SELECT * FROM hotels WHERE rating= " & rating & " "
If Request.Form("parking") = "yes" Then sql = sql & "AND parking = True "
If Request.Form("swimmingPool") = "yes" Then sql = sql & "AND swimmingPool = True "
If Request.Form("bar") = "yes" Then sql = sql & "AND bar = True "

'retrieve fields from the database (using SQL statement) 
results.open sql, connect, 3, 3
%>

<h4>HotelNet.com</h4>

<div class = "middle">
<h3>Search Results</h3>
<p>Results found for <%=rating%> star hotels with the following facilities:</p>
<ul>
<%If parking = "yes" Then%>
<li>Private parking.</li>
<%End If%>
<%If swimmingPool = "yes" Then%>
<li>Swimming pool.</li>
<%End If%>
<%If bar = "yes" Then%>
<li>Bar with entertainment.</li>
<%End If%>
</ul>

<table>
<!-- this loop will continue until all the records in 'results' have been read -->
<% Do until results.EOF %>
<tr>
<!-- output the value in the named field -->
<td><a href="hotelDetails.asp?name=<%=results("name")%>"><%=results("name")%></a></td>
<td><img src="images/<%=results("rating") & "star.gif"%>" /></td>
<td><%=results("description")%></td>
<td><span class="red">£<%=results("price") & " per room per night"%></span></td>
<td><%=results("city")%></td>
</tr> 	
<% 
' move to the next record in 'results'
results.MoveNext
loop%>
</table>


<p><a href="index.asp">home page</a></p>



</div>


</body>
</html>
 
weird, never thought it could be a browser issue, assumed there was an error in my code. Im on IE7, may download Firefox just to see
 
in the future design the site in firefox/safari/opera/chrome, which ever you prefer, and then include work arounds for ie. i find this the easiest way as firefox will typcially render as i'd expect and then it's easy to use a conditional statement to add a few lines of code that only the 3 ie browsers see to fix the few problems.
 
Last edited:
Why's it bad?

I use that sometimes for quickness and it always works.

because the idea of css is to keep styling and html seperate. inline styling should only really be used as a last resort, e.g. html emails.

when you start making massive dynamic sites which need to be redesigned with the site still live, it will be far easier to see why there is a gap between the table by simply looking at the stylesheet, where as having it all over the place will make it messier not only to update the styling but also if you have php/javascript/html and then styling all for one element it quickly becomes confusing what's what.

plus it also takes more time to add the code your way then it is to simply add margin-bottom: 10px to the table.
 
because the idea of css is to keep styling and html seperate. inline styling should only really be used as a last resort, e.g. html emails.

when you start making massive dynamic sites which need to be redesigned with the site still live, it will be far easier to see why there is a gap between the table by simply looking at the stylesheet, where as having it all over the place will make it messier not only to update the styling but also if you have php/javascript/html and then styling all for one element it quickly becomes confusing what's what.

plus it also takes more time to add the code your way then it is to simply add margin-bottom: 10px to the table.

well i sued the inline to be quick. I guess you'd use <div class="spacer"></div>. I take your point about inline styles though.
 
well i sued the inline to be quick. I guess you'd use <div class="spacer"></div>. I take your point about inline styles though.

No you wouldn't. All you've done is replaced <br /> with a <div> which does nothing which means you haven't got the point about separating style and content.
 
Back
Top Bottom