Put a colon at the conclusion of both of these titles

Here is the form code:

<form method="post" action="https://www.publictalksoftware.co.uk/wp-login.php" class="bbp-login-form">
  <fieldset class="bbp-form">
    <legend>Create an Account</legend>

    <div class="bbp-template-notice">
      <p>Your username must be unique, and cannot be changed later.</p>
      <p>We use your email address to email you a secure password and verify your account.</p>

    </div>

    <div class="bbp-username">
      <label for="user_login">Username: </label>
      <input type="text" name="user_login" value="" size="20" id="user_login" tabindex="101">
    </div>

    <div class="bbp-email">
      <label for="user_email">Email: </label>
      <input type="text" name="user_email" value="" size="20" id="user_email" tabindex="102">
    </div>

    <p><label>Security Question</label></p>
    <p>
      <select name="seq_ques[]" class="input" style="font-size:14px; height:35px;">
        <option value="16">"Sing Out Joyfully to Jehovah" Scripture?</option>
      </select><label>Your Answer<br><input type="text" name="seq_ans[]" id="seq_ans[]" value="" class="input"></label></p>
    <div class="anr_captcha_field">
      <div id="anr_captcha_field_1" class="anr_captcha_field_div">
        <div style="width: 304px; height: 78px;">
          <div><iframe src="https://www.google.com/recaptcha/api2/anchor?ar=1&amp;k=6Lc061QUAAAAAHzXUIbnlghp8LcJD1x5EtlRfrQi&amp;co=aHR0cHM6Ly93d3cucHVibGljdGFsa3NvZnR3YXJlLmNvLnVrOjQ0Mw..&amp;hl=en-GB&amp;v=66WEle60vY1w2WveBS-1ZMFs&amp;theme=light&amp;size=normal&amp;cb=1bfdqzy83l4n"
              width="304" height="78" role="presentation" name="a-wtj5g7sxqs30" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox"></iframe></div>
          <textarea
            id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea>
        </div>
      </div>
    </div>
    <div class="bbp-submit-wrapper">

      <button type="submit" tabindex="103" name="user-submit" class="button submit user-submit">Register</button>


      <input type="hidden" name="action" value="register">
      <input type="hidden" name="user-cookie" value="1">

      <input type="hidden" id="bbp_redirect_to" name="redirect_to" value="?checkemail=registered"><input type="hidden" id="_wpnonce" name="_wpnonce" value="19d211952c"><input type="hidden" name="_wp_http_referer" value="/register/">
    </div>
  </fieldset>
</form>

Here is a fiddle:

https://jsfiddle.net/jvawo134/

My actual page is here.

It displays a form:

https://i.sstatic.net/mDeWh.png

Can CSS be used to append : after the last two labels in this specific form only:

  • Security Question
  • Your Answer

Some context: The two labels mentioned are added by a WordPress plugin to the form. As per the given solution, additional CSS styling can accomplish half of the task:

.bbp-login-form fieldset p label:after {
  content: ':';
}

This will add a colon to the first label but adding it to the second label is tricky. Looking at the code:

<label>Your Answer<br>
       <input type="text" name="seq_ans[]" id="seq_ans[]" value="" class="input">
</label>

You see? We need to insert : just before the <br> tag for this label, and I'm encountering difficulty achieving that. Currently, using the snippet above, the colon ends up after the input box.

Update

Since the label is within a p, I applied this styling for the first label:

.bbp-login-form p label:nth-child(1)::after {
  content: ':';
}

So the first one is now working.

Update

Following the advice provided, I have included more CSS that works:

.bbp-login-form p label:nth-child(2) {
  font-size: 0;
}

.bbp-login-form p label:nth-child(2):before {
  font-size: 16px;
  content: "Your answer:";
}

The downside is that the final input box has reduced in height.

Final CSS

.bbp-login-form p label:nth-child(1)::after {
   content: ':'
}

.bbp-login-form p label:nth-child(2) {
  font-size: 0;
}

.bbp-login-form p label:nth-child(2)::before {
  font-size: 16px;
  content: "Your answer:";
}

.bbp-login-form p input {
    font-size: 12px !important;
}

Answer №1

If you want to add a colon after certain labels, you can use the ::after pseudo-element and set the content property to a colon.

.with-colon::after {
  content: ':';
}
<label class="with-colon">My Label</label>

If you don't have the option to add specific classes to the labels, there are a few ways you can achieve this:

  1. Inspect the injected markup to see if any elements have classes you can target.
  2. Use the :nth-child selector to target specific labels within the form.
  3. Alternatively, you could remove colons from other labels and then target all labels in the form with the ::after pseudo-element.

Answer №2

If you want to customize the security question label, you can achieve it using CSS:

.bbp-email + p > label:after {
    content: " :";
}

For modifying the Your Answer Label with JavaScript, you have a couple of options. You can use the following script:

 jQuery(document).ready(function($){
$('.bbp-email + p + p > label').html('<label>Your Answer:<br><input type="text" name="seq_ans[]" id="seq_ans[]" value="" class="input"></label>');
});

Alternatively, you can directly add the JavaScript code to your functions.php file:

function add_this_script_footer(){ ?>
<script type="text/javascript> 
jQuery(document).ready(function($){ 
$('.bbp-email + p + p > label').html('<label>Your Answer:<br><input type="text" name="seq_ans[]" id="seq_ans[]" value="" class="input"></label>'); });
</script>
<?php } 
add_action('wp_footer', 'add_this_script_footer'); ?>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps for adding a background image in ASP.NET MVC4

I recently removed the reference to the master page from the head section @{ Layout = null } After making changes in my CSS: html { background-image:url('Images\BGP.jpg'); } However, I didn't see any changes. Any suggesti ...

A single status update triggers numerous calls to the getStatus function within the Lync platform

Utilizing an ActiveXObject for managing lync status changes and displaying presence through the provided javascript code: var Instant = { sipUri: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99f7f8f4fcd9f8fdfdebfceaeab7faf ...

Positioning an image at the bottom left of the page using absolute positioning is simply not effective

Can anyone help me figure out how to make an image stay just above the footer on the bottom left-hand side of the main content? I've tried using floats, margins, and positioning on left nav elements without success. Here's a link to see what I me ...

The min-width of 100vh is functioning properly on mobile devices, however, it is not working as expected on PCs when set to 100

When using 100vh, it only works on mobile or if you narrow the width of your web browser on a PC. If the window/width is set at 100%, the image may appear too tall and cause the div class "mars" to overflow the viewport. Unfortunately, screenshots cannot ...

Load an external script once the page has finished loading by leveraging the power of $(document).ready() in conjunction with $.getScript()

Is it possible to load a script in the header of a website instead of at the bottom? I've been trying but it's not working as expected. Here is an example of what I'm attempting: HTML file: <!DOCTYPE html> <html lang="en"> < ...

How can I align navigation items to the right in Bootstrap 4?

Is there a way to align the navigation items to the right in a Bootstrap 4 navbar? I attempted using float-*-right but it didn't produce the desired result. <nav class="navbar navbar-static-top navbar-dark bg-inverse float-*-right"> <a c ...

Move the contents of a div to the right side

One of the issues I am facing is with aligning replies to comments correctly in my comment section. The replies are not aligning properly with the parent comment and it's causing a display problem. Link to JSFiddle for reference Here is the CSS code ...

retrieve the parent id of <ul> elements and store them in an array

Here is the html code I am working with : <form> <ol> <li id="1" name="grandparent">Grand Parent <ol> <li id="2" name="parent">Parent <ol> <li id="3" name="child">Child < ...

SQL queries can be used in Node.js to fetch data from various tables and display it on an HTML page

I have a problem with my expressjs app where I am trying to count records from multiple tables in a database and display the results on separate divs in HTML. Currently, the code is functional without any errors, but I am encountering an issue where the sa ...

Angular - iterating through arrays with the *ngFor directive

One tag is not showing up in my Angular project when using *ngFor. The issue occurs with and without the *ngFor directive. Any solutions or suggestions are greatly appreciated. Thank you! ...

Having difficulty in getting the heading to align with the left side

Looking for some guidance on creating a dynamic page similar to this DemoPage. The goal is to have the content editable and pulling data from the backend. However, I am facing challenges in achieving the desired layout as shown in the sample page CreatedPa ...

What is the process for generating and launching an HTML page straight from LocalStorage?

Using JavaScript, HTML, CSS, and potentially PhoneGap if desired, is there a way to create and launch a basic html page directly from LocalStorage? I am looking for a personalized HTML page that can be accessed online on my iPod initially, but then offline ...

Are you familiar with PowerShell and its innovative modular GUI capabilities?

One challenge I face is assisting clients who constantly monitor the performance of their servers, services, and network. Utilizing PowerShell, I envisioned creating a unified GUI interface for all these tasks, including remote log tailing capabilities. B ...

CSS - Fixed header does not move when scrolling

Hey there! I'm working on an Angular application where I've set up sticky Filters and Header rows using HostListener and window scroll. However, I've encountered a small issue where the content of both the Header and filters overlaps with th ...

Dynamic Product Showcase using Bootstrap Framework

Currently, I am working on creating a product listing section for a hypothetical e-learning website that I'm developing. The top image is intended for desktop viewing, while the bottom one is optimized for mobile users. https://i.sstatic.net/vq8R2.p ...

Ensuring that the text-box is the same size as the image

I am encountering two challenges: When scaling the window down horizontally, I am facing an issue with aligning the images on the left (sideImage) vertically with the text box. I have attempted using margin-top auto and margin-bottom auto, but that doe ...

Adaptable picture within a bootstrap container

I need help figuring out how to insert an image into a Bootstrap panel (see attached image): https://i.sstatic.net/BHQI9.jpg Here is the HTML Code I am using: <div class="panel panel-default col-md-10 col-md-offset-1"> <div class="panel-bod ...

If the option is 'Gel', use an if statement to console log

I'm trying to console.log the option from the data() function that is equal to 'Gel'. I attempted to use an if statement, but it doesn't seem to be working. Anyone have any ideas on how to make this work? data(){ return { ...

Creating input fields in Angular 2

Can someone guide me on how to sum the values entered in two input fields? Here is my HTML code snippet. I'm not sure if there's anything missing in the ts file. <div class="small-7 columns"> <md-input-container> <input t ...

Integrate a PHP link into a Gatsby/React project

I've been attempting to connect my contact form page, contactpage.php, with my Gatsby application. In the navigation bar (found in the Components folder), I've added the following code: <div> <a className="int_link_about" ...