CSS style setting in <p> not working - Codeigniter
This code below does not apply the class mentioned in the p tag in chrome, but works in IE, Firefox<p class="p_error"><?php print $this->validation->errorValue;?></p>Here CSS -> .p_error{ color:red; text-align:left; font-size:12px; }
Any hint or reason why its not working?
From the chrome outlet → using the control element →
<p class = "p_error"> </p>
<p> Required field Processed field. </p>
By default, the system adds a paragraph tag ( <p> ) around each displayed error message. You can easily change these delimiters using this code placed in your controller:$this->validation->set_error_delimiters('<div class="error">', '</div>');
for reference: http://codeigniter.com/user_guide/libraries/validation.html>
This is the code generated by the PHP script:
<p class="p_error"><p>The Treated By field is required.</p></p> The HTML specification states that:
- P element cannot be inside another P element. Tag
</P>may be omitted (implied)
These rules mean that you can write something like this:
<p>First paragraph <p>Second paragraph The browser will automatically close the first paragraph (i.e. add </P> ) to the second <p> .
In your case, this means that the error ends outside the p_error paragraph, as the check item shows:
<p class="p_error"></p> <p>The Treated By field is required.</p> Just <p> cannot wrap <p> . This way the browser will be confused if you give it <p><p>content</p></p> . You can either use the shell built-in arguments:
<?= form_error('lastname_error', '<p class="p_error">', '</p>'); ?> Or wrap it all in an element that can wrap a <p> , such as a <div> .
<div class="p_error"><?php print $this->validation->lastname_error;?></div> Of course, you will need to style the div instead of p .
By default, the system adds a paragraph tag ( <p> ) around each displayed error message. You can easily change these delimiters using this code placed in your controller:$this->validation->set_error_delimiters('<div class="error">', '</div>');
for reference: http://codeigniter.com/user_guide/libraries/validation.html>
There is nothing in your <p class="p_error"></p> so that nothing is displayed. If you want to show individual errors , you should use
<?php echo form_error('your_field'); ?> and for style
<?php echo form_error('your_field', '<p class="p_error">', '</p>'); ?> Important note: insde your view, $this does not work, because the class context is required to work.