HTML / CSS table with GRIDLINES
Asked Answered
R

3

59

how do I display the gridlines in a HTML table? (am using IE6)

Ralph answered 19/11, 2009 at 12:40 Comment(1)
What do you mean by gridlines?Bronder
D
110

Via css. Put this inside the <head> tag.

<style type="text/css" media="screen">

table{
border-collapse:collapse;
border:1px solid #FF0000;
}

table td{
border:1px solid #FF0000;
}
</style>
Distributary answered 19/11, 2009 at 12:43 Comment(5)
Use <style type="text/css"> instead.Outnumber
the border-collapse on tds is superfluous (and in fact not standard).Brio
one more question - how do I make the vertical lines solid, and the horizontal lines dashed?Ralph
border-left: 1px solid black; border-right:1px solid black; border-bottom:1px dotted black ( or dashed)Distributary
Useful for figuring out layout problems!Rundgren
D
27
<table border="1"></table>

should do the trick.

Deutoplasm answered 19/11, 2009 at 12:43 Comment(5)
Should work, but it's better to separate content and design (content in html, design in css, where border is design.Outnumber
Agreed, but sometimes it's ok to bend the rules a little too :)Deutoplasm
This is great for troubleshooting when using colspan a lot. Being able to add or remove border='1' is much simpler than messing with css.Montmartre
This only displays a border around the table, right? So there's no distinction between columns and rows.Kimberleekimberley
@EricDuminil this is a very old answer and browsers may render differently these days. Back then most (all?) browsers would cascade the property to table elements.Deutoplasm
J
1

For internal gridlines, use the tag: td For external gridlines, use the tag: table

Johny answered 13/4, 2015 at 17:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.