Topology optimization can be seen as optimizing a distribution of small topological elements within a domain with respect to given specifications. A numerical topology gradient (TG) algorithm is applied in the context of electromagnetism for optimizing microwave devices, computing the sensitivity on adding or removing small metallic elements. This method leads to an optimum topology with very little initial information in acceptable time consumption. The method is applied to the design of a microstrip component in which the topology gradient is directly used as a direction of descent. However, in some ill-behavior problems, topology gradient is not sufficient to converge to the global optimum. In the latter case, the basic TG is coupled with a genetic algorithm (GA) to make a more suitable algorithm for solving local optima problems.