I just read a post that says:

When Angular bootstraps your application, the HTML compiler traverses the DOM matching directives against the DOM elements.

What does "match... against" mean? How should we should use it?

  • Hmm. Dictionaries don't make finding an appropriate definition easy! ODO | Cambridge | MW. Even match against doesn't really help: ODO
    – Andrew Leach
    Jul 8, 2014 at 7:10

3 Answers 3


This is almost more a web applications question than an English one, but since the word match here has a more general utility in other areas than web applications, I'll attempt a general answer. If you want something more detailed about HTML or HTML5, I suggest posting followups to webapps.stackexchange.com.

"DOM" is an acronym for "Document Object Model", about which you can read more here. The idea of the sentence is that the web language HTML 5 reads a list of elements in an HTML page, and reads a list of directives that pertain to each list. A very rough analogy is to think of making a number of purchases something by mail order from the same supplier. When you receive the order, you will take the packing list (comparable to the list of DOM objectives), and check off the items on the list with the items in the actual shipment to make sure they match. If the order is complete and accurate, the packing list should match the order, that is, there should be a one to one correspondence between the items on the list, and the items in the order.

For the more general question, about how to use "match ... against", it would be useful any time you have a list of some entity, and you need to check to see which of the items on the list are there, and which (if any) are missing. So in a gathering of people (like a meeting or a class) you would match the actual attendees against the list of those who are supposed to attend. Or, returning home from a shopping trip, where you forgot the list of things you intended to purchase, checking of the items you actually bought against those that you intended to buy. Or, with an automobile, where you have reached a certain number of miles, matching the maintenance you have actually done, with the suggested items in the owner's manual of the auto. One could also match two lists against each other.

In most cases, match ... against would be a parallel usage to "compare ... to".

  • In this case, though, isn't it more like "pair with" than "compare to"?
    – Rupe
    Jul 8, 2014 at 9:12
  • Not the way I've seen it used. If I have one horse, and want to put another with it to make a team, I "pair the second horse with the first". If I have a note listing the two horses to be in the team, I compare the horses I have to the list of names. In the case of the text the OP provided, there is a collection of DOM elements, and a separate list of DOM directives, which get compared to the various elements on the list, though to be completely honest here, I'm rather beyond my actual knowledge here.
    – brasshat
    Jul 8, 2014 at 9:26
  • 1
    My point is that "compare to" is less specific. Yes, the lists are being compared to each other, but that could for example also mean that the lists are being counted to see which is bigger. In this case, if I understand it right, the comparison of the lists is done to associate elements from one list with elements from the second list. That's a more specific operation than mere comparison. Note also that in the sentence provided, it is the elements of the lists that are being "matched against" each other, not the lists themselves.
    – Rupe
    Jul 8, 2014 at 9:31

HTML is a syntactic language for defining webpages. While it can be leveraged to apply styling and scripted instructions to its objects, it is best utilised in defining the structural elements of a document, and hooking associated CSS stylesheets and JavaScript handlers and methods to these elements from separate files.

These three languages together encompass a similar concept of separation of responsibility to the MVC design methodology, and each is optimised for its intended use, whether that is defining and categorising objects (HTML), defining object styles (CSS), or performing operations on content to produce some result that was not originally present in the document when it was written (JavaScript).

Angular is an extensible JavaScript library that manages much of this process for you, simplifying the creation of dynamic content to produce interactive or responsive webpages. It does this in essence by taking the instructions defined within it and applying them to the DOM objects with which they are associated.

Consider following a recipe, which consists of a list of ingredients (analogous to HTML objects) and a list of operations to be performed with them (analogous to JavaScript instructions). When you get out the knife and chopping board, you will match the action of slicing/dicing/peeling with the elements to which they are applied in the instructions: dice the onion; peel the potato. The idea in your quote is the same, it is simply defined with enough rigour to allow a machine to perform it unambiguously.


What is being described is that "directives" are being matched against "elements". That is, each directive is relevant to none, one or more of the available elements, and it's applied to those elements as required.

The closest dictionary definition of against is Cambridge's touching, although it's hardly ideal:

next to and touching or being supported by (something):
Why don't we put the bed against the wall?
He loved the feel of her soft hair against his skin.
The rain beat against her face as she struggled through the wind.
The police officer had him up against the wall, both arms behind his back.
She leaned against the door.

in front of or compared to:
Paintings look best against a simple white wall.

A similar concept is illustrated by tally-sticks:

Tally sticks

These are laid against (touching) each other, in order that the notches and marks in them can be compared and verified. Each notch in one stick needs to match a notch in the other. The notches are matched against each other. In the case of tally-sticks, they show payments made or due to the Exchequer: each notch is a particular amount of currency, so the notch for £100 needs to be matched with an identical notch in the other stick.

One idiomatic aspect of match against which is not present in match with is a concept of process. If notches are matched against each other, there is a process to verify that each notch in turn matches its counterpart. In the question's example, the verb traverse indicates a multi-step process which necessitates using against.

(Illustration of tally-sticks from David Astle)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.