0

I have this String, that consists of HTML syntax, but there are some CSS tags also, for example :

<style type='text/css'> #gallery-1 { margin: auto; } #gallery-1 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 25%; } #gallery-1 img { border: 2px solid #cfcfcf; } #gallery-1 .gallery-caption { margin-left: 0; } /* see gallery_shortcode() in wp-includes/media.php */ </style> 

And I would like to change width: 25%; to width : 100%; with the help of JSOUP. How can I access the CSS tags in String like this ?

1

1 Answer 1

1

Jsoup does not parse CSS, but if you only care about this particular page, you can change the element's text: element.text(element.text().replace("width : 25%;", "width : 100%;"));

For more general CSS transformation, you'll want an actual CSS parser, such as the one suggested in Shahrukh's comment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.