Different ways to hide an HTML Element

There are different ways to hide an HTML element from the client, just hiding not removing.

We need to hide p.hide element, so the user can’t see it.


Display css property, display is the most important and most used css property to control HTML elements layout.

display:none; can be used to hide an HTML element from the view and it will appear as if it was not there on the page, means the HTML element will be hidden without blocking any space.

Example: Text 1 | Text 2 | Text 3

If we apply display:none; on Text 2, it will be: Text 1 |  | Text 3

So to hide p.hide element using display property:


Visibility property is the CSS property to manage HTML visibility, unlike display which has different values to control the element layout, visibility is used jut for show and hide elements

visibility: hidden can be used to hide an element from the client, but it will keep the element space visible like this: Text 1 |        | Text 3

When to use which? based on requirements and the case you have, you just need to test it on all browsers, and there will be an unrecognizable performance differences between different ways



Opacity property is controlling the transparency of the html element, so we can use it to make the element fully transparent and this will hide the element from the client view.

Just make sure to test it on all browsers because on older IE browsers it had some special ways to implement. (hope that no one still using old IE browsers, because the wont see many things any way 🙂 )

And the same as Visibility property, it will hide the element but will keep blocking its space, so the client will see an empty space instead of the element.

Background color and color

While it is rarely used, but we can change the background-color element css property and all child elements to be the same as the background color of the page or the same as container background.

Will need to change the text color as well to make sure that text is not visible as well.

And on some elements we may need to remove borders, that’s why this way is not common to use.

Font size:

We can hide text elements by setting font-size property to 0


Using the position property and top left we can make the control appear outside the client view.

Clip-Path (Clip):

Last way I want to mention on this post is using clip-path css property








Posted in Technical | Tagged , | Leave a comment

Simplest menu using CSS

Many web designers I met had problems while  creating menus, specially which contains nested sub menus.

In some cases it is a real pain, but in most of cases it is simple, and the problem come when the designer start to implement the simple menu the hard wrong way, it will take ages from him to implement a simple menu while it just need few lines of css code.

Also he may think it can’t be done without javascript and jquery.

Try to think simple while writing your next menu and may be you will need my code as a starting point for a more complex menu.

What I am listing here is a very simple menu, putting in mind that this menu may contain infinite number of submenus.

Lets start with html:



This html use UL and LI to draw the menu html, you can use divs instead of UL and LI, this will not cause a problem.

The only hint I can point about the previous html code is that the sub menus html are inside the parent menu html.

Such as ‘Sub 1 >>’ is inside the parent ‘Main 1’, this will make our job easier.

Next CSS:

 ul li ul li
clear: both;

list-style-type: none;
float: left;
margin: 0 10px;
cursor: pointer;

li ul
display: none;
padding: 0;

li:hover > ul
display: block;

The most important lines for us are starting from line 15, everything before this is just for making things looks better and formatted better.

As you see it is just 4 lines of code to make the menu functional, the trick exists in line 21, which will show the UL which exists under any LI and the user hovered on it, and the ‘>’ means that we will show just the first level of UL not all nested UL.

Feel free to add more nested submenus and see how simple it is.


Posted in Technical | Tagged , | Leave a comment

it’s weekend, facebook shoooooooo

I am not using facebook that much, I just open it for few moments everyday to check my friends news, But rarely I put a status or upload a picture there.

The question I have is: why employees get angry when their companies decide to block facebook during working hours?

By the way I don’t respect a company which do this, this is the last last step after many discussions with their employees.


After monitoring facebook, and my friends activities during all week days, I can say that: the number of posts on facebook get 95% down in weekends, get 50% down after working hours, and really the peak time for facebook is during the working hours. “all numbers are estimated and just based on my own experience

In my point of view, the employer pay us salaries to get from us work, for example he pays us 100$ per week to work 40 hours per week, 8 hours per day, so our salary = 40 hours work including a rest hour per day.

So if you take all this time daily on facebook or chatting, do you think you deserve this salary? “if the answer yes: sorry this post came to you by mistake discard it 😉


Other notes:

I know many workers I worked with, facebook is a permanent browser tab, never close it.

I know others, just open facebook on weekends “may be something bad also for their families 😀

Posted in Geeky Life | Tagged , , | Leave a comment

Avoid sending Ajax request parameters in query string style

While reviewing some code, I found someone calling jQuery Ajax like this:

       type: “POST”,
       url: “/AddPost”,
       data:  “postText=”+ PostText ,
       dataType: “json”,
       success: function (status) {

}); //$.ajax({

And as you see in the previous code, it is sending the data using this line: data: “postText=”+ PostText ,

This is like a query string style, this will work well but image the user inserted a special char in PostText, such as ?? you will get on the server un expected value “”jQuery15107041011152323335_1309357585354″”

So never use this style while dealing with Ajax calls, you need to post it in JSON style like this:

        type: “POST”,
        url: “/AddPost”,
        data: { postText: PostText },
        dataType: “json”,
        success: function (status) {

}); //$.ajax({

This will work whatever char the user will insert.

Posted in Technical | Tagged , , | Leave a comment

EF 4.1 Released

The final Release to Web (RTW) of Microsoft ADO.NET Entity Framework 4.1 (EF 4.1). This is a fully supported, go-live release.


Posted in News | Comments Off on EF 4.1 Released

Javascript based Data Grids



I found in this blog post some good javascript based grids http://www.queness.com/post/7300/7-robust-and-feature-packed-javascript-grid-plugins


Here are their links:

1- http://flexigrid.info/

2- http://www.webismymind.be/editablegrid/

3- http://www.trirand.com/blog/

4- http://tablesorter.com/docs/

5- http://www.datatables.net/

6- https://github.com/mleibman/SlickGrid/wiki

7- http://blog.jqueryui.com/2011/02/unleash-the-grid/

Posted in Technical | Comments Off on Javascript based Data Grids

Ajax loading gif images generator

I used to use this web site http://www.ajaxload.info/ to generate ajax loading gif images.

Today I found another nice website and it gave me more options to generate custom images: http://preloaders.net


another simple tool: http://fgnass.github.com/spin.js/

Posted in Technical | Comments Off on Ajax loading gif images generator

List of Colors in System.Drawing.Color

Few lines of code to print all System.Drawing.Color colors on a web page.

loop on System.Drawing.Color using KnownColor



Posted in Technical | Comments Off on List of Colors in System.Drawing.Color



Posted in Stream | Comments Off on 29!

How to hide users files and folders on your website?

Sometimes you want to hide some files or folders on your website, so that no one can access them directly.

If you have an upload feature in your website, and your website users upload their files or images to your website, It will not be nice to let other users see others files by guessing the URL.

For example: Your website uploaded files directory is “UsersUploads” and you put there all the users files, so one file url will be www.example.com/UsersUploads/File1.pdf, another will be www.example.com/UsersUploads/File2.doc .

Now a user can guess the URL and access others files specially if your files names are easy to guess.

There are two solutions for doing that:

1- You can put your “UsersUploads” folder outside the website directory, so if your website exist on “c:\website\example.com” you can put the “UsersUploads” there “c:\UsersUploads”, Like that IIS has no control over this folder and its files, And your website code will still have access to this directory as a normal physical path.

2- Stop IIS from serving this folder:

IIS by default doesn’t server some website folders and files such App_Data, App_Code, bin, App_GlobalResourses, App_LocalResources, Web.config,….

You can configure IIS to stop serving some more files or folder inside your website folders by Adding a new Hidden Segment.

– Select your website in IIS, and open Request Filtering.

– Go to Hidden Segments tab.

– In the right Actions panel click on “Add Hidden Segment…”.

– Write there the file or folder name you want to hide.

– This will edit your website web.config file and add the following:


Now users can’t access this folder directly by guessing the URL.

Note that you can do this manually without the IIS by editing your website web.config file and put there the same values.


I believe that there are more ways to accomplish the same thing, but these are 2 easy ways.

Posted in Technical | 2 Comments