2
<div style="width:100%">
       <div width="200px">dsffffffbgsf</div>
</div>

Suppose I have an html string.The above is just an example it can be any valid html string.

Here width of an element can be specified as just width or using style. How can we get the total width of the html content,using c#?

zey
  • 5,939
  • 14
  • 56
  • 110
Kuttan Sujith
  • 7,889
  • 18
  • 64
  • 95
  • Are you wanting to find the width css property value or the actual width on the page once rendered? – Dan Lister Jul 04 '13 at 07:25
  • Assuming you're running this in a browser, you cannot use C# to compute the width of the div. You have to use JavaScript instead. Refer http://stackoverflow.com/questions/294250/how-do-i-retrieve-an-html-elements-actual-width-and-height – Pranav Negandhi Jul 04 '13 at 07:50

1 Answers1

0

Are you talking about the html or the related css for a html page?
I would say that you might look at parsing the html with the Html agility pack.
If you are looking at the css, then have a look at Fizzler, which looks at the css for a page. Fizzler is using the html agility pack under the hood.

weismat
  • 7,195
  • 3
  • 43
  • 58