Syntax for imposing the boundary condition in variational form

the syntax for imposing explicity the boundary condition in variational form at H^1/2 norm i.e. u=g is on boundary and g belongs to H^1/2. what is the syntax for this?