Farok Ojil
Farok Ojil

Reputation: 654

Get dimension of HTML tag

I'm using PHPQuery parse HTML file and I need the height and width of a given tag, in jQuery it's possible to use something like

height=$("div.content").height();
width=$("div.content").width();

but in PHPQuery there is no such thing as height(), width() functions so is there any way to get the dimensions?

Upvotes: 0

Views: 170

Answers (1)

cdhowie
cdhowie

Reputation: 169403

PHPQuery just lets you traverse the document in a manner similar to jQuery. It does not actually render the document and so it has no idea what size each element will actually be when rendered by a browser.

In order to compute the width and height of an element, it would need to parse your stylesheet, apply all of those rules, fetch any images used by that element (and its descendants) and render the element using the appropriate font(s) -- and possibly even render parent elements as well. And there's no guarantee that the resulting dimensions will match some particular client configuration, since the client-side environment may cause the element to render at a different size (DPI being the most obvious example, but even the size of the browser window could affect the size of any given element).

Upvotes: 1

Related Questions