views:

32

answers:

2

Hi All,

I Have faces a issue with removeing alignment In HTML document.

 <html>
  <head>

  </head>
  <body>
    <p style="margin-top: 0" align="center">
      Hello World
    </p>
    <p style="margin-top: 0" align="center">
      Java World
    </p>
  </body>
</html>

My Issue is how to remove alignment of first paragraph with out affecting second paragraph . If I use regex it will it will remove alignment of second para also. I really appricite you any comment regarding this issue.

+1  A: 

Use the replaceFirst function.

Ilian Iliev
A: 

I'd like to show you another way for that. It would be quite simple to use CSS pseudo-class: :first-child. According to your code above:


body p:first-child { text-align: left !important; }

Second thing would be to use JavaScript or any JS library, like jQuery to remove this property from first p element, e.g.:


$(document).ready(funtion(){
    $("p").first().css("text-align","left");
});
Ventus
AFAIK pseudo classes are not well implemented(supported) in all browsers(http://www.webdevout.net/browser-support-css#css2pseudoclasses)
Ilian Iliev