We consider unranked trees, that have become an active subject of study recently due to XML applications, and characterize commonly used fragments of firstorder (FO) and monadic second-order logic (MSO) for them via various temporal logics. We look at both unordered trees and ordered trees (in which children of the same node are ordered by the next-sibling relation), and characterize Boolean and unary FO and MSO queries. For MSO Boolean queries, we use extensions of the µcalculus: with counting for unordered trees, and with the past for ordered. For Boolean FO queries, we use similar extensions of CTL⋆ . We then use composition techniques to transfer results to unary queries. For the ordered case, we need the same logics as for Boolean queries, but for the unordered case, we need to add both past and counting to the µ-calculus and CTL⋆ . We also consider MSO sibling-invariant queries, that can use the sibling ordering but do not depend on the particular one used, and capture th...