Why are cellspacing and cellpadding not CSS styles
Solution 1
table { border-collapse: collapse; }
As for cellpadding, you can do
table tr td, table tr th { padding: 0; }
Solution 2
Eric Myer's reset stylesheet contains the following 'reset' style for table :
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
In addition TD, TR are reset :
thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
The reason I mention this is that he has a comment 'tables still need cellpadding=0'. I assume he put this in here for a reason - probably needed by some old browsers. Judging by the fact that this is one of the very few comments he included I'm guessing its important and that there's a good reason for it.
Based on this comment - and this comment alone! - i'm continuing to use cellspacing="0" in the markup unless someone tells me definitively (below) why I dont need to. It could however likely be unnecessary in any modern browser worth supporting these days.
Aqeel Abbas
Updated on June 18, 2020Comments
-
Aqeel Abbas about 4 years
I am trying to read a file which include some commands that i want to be copied to clipboard. On searching internet i have found a way how to copy data into clipboard which i have done successfully. However i have to copy multiple commands. which i am doing in a while loop. Here is my code.
{ class Program { [DllImport("user32.dll")] internal static extern bool OpenClipboard(IntPtr hWndNewOwner); [DllImport("user32.dll")] internal static extern bool CloseClipboard(); [DllImport("user32.dll")] internal static extern bool SetClipboardData(uint uFormat, IntPtr data); [STAThread] static void Main(string[] args) { int counter = 0; string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(@"C:\Users\st4r8_000\Desktop\office work\checks documents\interface check commands.txt"); OpenClipboard(IntPtr.Zero); //int x; while((line = file.ReadLine()) != null) { Console.WriteLine (line); //clip board copier var yourString = line; var ptr = Marshal.StringToHGlobalUni(yourString); SetClipboardData(13, ptr); Marshal.FreeHGlobal(ptr); Console.ReadLine(); //end of clip board copier counter++; //ptr = x; } CloseClipboard(); file.Close(); // Suspend the screen. Console.ReadLine(); } } }
So the problem i found is in the following line
Marshal.FreeHGlobal(ptr);
or may be inSetClipboardData(13, ptr);
but i do not know how to resolve this. This runs very fine in the first go but in second or third the program stop responding. Any help will be greatly appreciated.I am not using windows forms. i am trying to build it in console.
-
DinosaurTom over 8 yearsFirst of all why do you use user32.dll? There is a Clipboard class and SetText method (explained broadly in stackoverflow.com/questions/3546016/…)
-
Dmitry Bychenko over 8 yearsWhy not
Clipboard.SetText()
? -
Aqeel Abbas over 8 years@DinosaurTom because i am not using windows forms. so i found out this as a solution.
-
Aqeel Abbas over 8 years@DmitryBychenko does
Clipboard.SetText()
works in console application ? -
Dmitry Bychenko over 8 years@Aqeel Abbas: Clipboard.SetText() should work with console applications as well; yes,
Clipboard
is in theSystem.Windows.Forms
which is misleading. -
Aqeel Abbas over 8 years@DmitryBychenko whenever i try to include
System.Windows.Forms
its say are you missing a assembly reference. I appreciate you help though :)
-
-
Ryan Smith over 15 yearsThanks for that, I never really understood what border-collapse was suppose to mean. I'll have to start using that instead of using the old HTML attribute way.
-
mat over 15 yearsWell, without border-collapse, if there are two adjacent cells with a 1px border each, you'll end up having a 2px border, because the borders are adjacents, with border-collapse, the borders are, well, collapsed :-)
-
Martha over 14 yearsNote that
border-collapse:collapse
produces a completely different visual effect thancellspacing="0"
; the two methods are not actually equivalent or interchangeable in any meaningful or useful way. -
Aqeel Abbas over 8 yearsI am very new to c#. i am facing problem in
foreach
line. its says cant convert type char to string. please check this out Errors -
Dmitry Bychenko over 8 years@Aqeel Abbas: ensure that you have two using (see my edit), do not use
StreamReader
at all - see my code:File.ReadLines(...)
; the last error is my fault (typo)if (clipBuffer.Length > 0)
-
Aqeel Abbas over 8 yearsI am creating console application. thats the reason i am using the dll thing. And i do not think so that in console application
System.Windows.Forms
can be used. -
Dmitry Bychenko over 8 years@Aqeel Abbas: why not? You can use any assemblies you want.
-
Aqeel Abbas over 8 yearsi got that. I am sorry as i am noob in it. I added a reference there and its okay now :)
-
Aqeel Abbas over 8 yearsone more little help if you can offer me. Please check this error
-
Dmitry Bychenko over 8 years@Aqeel Abbas: looks like stackoverflow.com/questions/3584434/… does the application work alone? Outside Visual Studio?
-
Aqeel Abbas over 8 yearsHavent tried anywhere else as currently i am only using VS 2012
-
Dmitry Bychenko over 8 yearsEnsure that
Main
is marked with[STAThread]
attribute.[STAThread] static void Main(string[] args) {...
-
Aqeel Abbas over 8 yearsyou are life saver :)
-
verdy_p about 4 yearsI downvote the "border-collapse:collapse" in CSS, which has a different purpose (its effect is effectively to also remove the spacing completely as it will merge the inner borders of cells by dividing them by 2). The correct answer is "border-spacing: n" in CSS for the cellspacing="n" attribute. "border-spacing:0" still does not collapse the inner borders or cells, they are just glued.