Arrangement of p tag and br tag in HTML

This is what I desire. https://i.sstatic.net/jhwrp.png

This is what I am receiving. https://i.sstatic.net/quwUN.png

This is the code I have written. I am struggling with the spacing. Aligning the p tag with the br tag is proving to be a challenge for me. I have attempted to use inline but it has not worked as expected.

<p class="one"><b>Field of</b> Select all that apply, hold CTRL when clicking to select multiple items <br>
  <b>study: </b></p><!-- This is where the issue lies. -->

Answer №1

Having two containers is recommended. Place the bold text on the left container with some unique styles. It may be challenging to troubleshoot your current code to solve the issue; starting fresh might be the easier solution.

To add space between texts, utilize padding, and to align the second line closer to the border, use text-align:right;. Here is an example:

.main_text {
   padding-left:5px;
}

.left_text {
  text-align: right;
}
<div style="display:flex">
   <div class='left_text'>
      <b>Field of <br> study: </b>
   </div>
   <div class='main_text'>
      <label> Select all that apply, hold CTRL when clicking to select multiple items</label>
   </div>
</div>

Answer №2


Let's simplify this,

Just add float: right to properly align the word "study". That's all!

Here is the code snippet:

.one {
  width: 55px;
  height: 50px;
}

.span {
  float: right;
}
<b>Field of</b>&nbsp;&nbsp;&nbsp;Select all that apply; hold CTRL when clicking to select multiple items
<p class="one">
  <b><span class="span">Study:</span></b>
</p>



CodePen: https://codepen.io/marchmello/pen/abOPJzp?editors=1100

Answer №3

If you're looking for precise placement, Flexbox is the way to go. Use align-items:center to achieve the desired positioning:

div{
display:flex;
align-items:center;
font-size:19px;
}

#a1{
display:block;
margin-right:14px;
width:64px;
}
<div>
<p id='a1' ><b>Field of <br/>Study </b></p>
<p>Select all that apply, hold CTRL when clicking to select multiple items </p>
</div>

Alternatively, you can use align-items:flex-start to achieve a different type of placement:

div{
display:flex;
align-items:flex-start;
font-size:19px;
}

#a1{
display:block;
margin-right:14px;
width:64px;
}
<div>
<p id='a1' ><b>Field of <br/>Study </b></p>
<p>Select all that apply, hold CTRL when clicking to select multiple items </p>
</div>

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

Why won't my sticky element function properly with the position attribute set to sticky?

Hey there! I've been diving into learning all about CSS positions and have nailed down most of them. However, for some reason, the sticky position just won't cooperate and is stubbornly acting like a relative one instead. Check out my HTML snipp ...

What methods can I implement to prevent my boxes from becoming stretched out?

How can I prevent this box from stretching too much? Here is the code snippet along with the output: CSS: .social { padding-left: 1000px; border: 5px inset black; margin: 4px; width: 100px; } HTML: <div class="social"> <p& ...

What's the best way to undo a CSS transition animation when deleting an active class?

I'm currenty working on a straightforward icon animation within a VueJS application. I've implemented a Vue transition to create a fade effect on the background elements, but I'm exploring options for a subtle upward shift animation specific ...

In what ways can the accessibility of a website be impacted by using CSS

After reading numerous articles on Google and Stack Overflow, I have decided to ask my question straightforwardly in the hopes of receiving a clear and direct answer. Adding another layer to the discussion about whether Does opacity:0 have exactly the sam ...

Switch out the arrow icon in the dropdown menu with an SVG graphic

Looking for a way to customize the dropdown caret in a semantic-ui-react component? Here's how it currently appears: https://i.sstatic.net/GpvfC.png <Dropdown className="hello-dropdown" placeholder="Comapany" onChange={th ...

How can I update the style of my array-bars using componentDidMount()?

I created a visualization tool for sorting algorithms that displays vertical bars with varying heights and sorts them. The "Generate new Array" button triggers a function to generate a new array each time it's clicked, which is also used in the compon ...

Is there a way to retrieve the filename of a file uploaded using a shiny fileInput function?

This shiny app has a feature where users land on the 'Upload data' panel upon launching. To restrict access to the other two 'tabpanels', users must first upload both necessary files in the 'Upload data' tab. The condition for ...

Manipulate DIV elements with jQuery by selecting them based on their class names and then

Is there a way to use jQuery to eliminate all DIVs on a webpage while preserving their content that have the following specific pattern? <div class="ExternalClass85AC900AB26A481DBDC8ADAE7A02F039">....</div> Please note that these DIVs adhere ...

Website issues being displayed by Internet Explorer

Greetings! Let me begin by saying how wonderful this page is - I have already found many answers here before. Please forgive any errors in my English :) In my efforts to optimize my website for SEO and increase its speed, I made several changes. The site ...

When the width of a single table is large, Bootstrap tables can appear misaligned and not properly

I am facing an issue with displaying two tables side by side. Whenever the width of the first table is too large, the second table is pushed below it. https://i.sstatic.net/w8zwp.png https://i.sstatic.net/SZdZU.png Is there a way to make them stay side b ...

Creating a vertical scrolling marquee to showcase a list in React - step by step guide

Trying to create a marquee effect that displays a list of items in a vertical auto-scroll. After reaching the end of the list, I want it to loop back to the beginning seamlessly for continuous animation. The code snippet below shows my progress so far - a ...

Looking to attach the "addEventListener" method to multiple elements that share the same class?

I'm trying to use an event listener in JS to handle the logic in the "onClick" function, but it's only executing once. I've applied the same class to all four buttons, so I'm not sure why it's only working for the first one. HTML: ...

html interactive/expandable tree

I've come across this code which generates an HTML tree, but I'm facing an issue where the tree expands every time I refresh the page. What I want to achieve is to have certain branches expanded and others collapsed when the page is opened, depe ...

Position a grid item in the center

Can someone help me with centering my container's item? I am struggling to align the third item to the center using display: grid. Previously, I attempted to use flexbox but found it to be less effective for a responsive layout. .projetos { f ...

The SQL query containing 6 SELECT statements combined with UNION operation resulted in a total of 2 rows being

The table that I'm working with has rows containing four different fields of numbers: people, debris, miles, and bags. As of now, all these fields are set to 0 because there is no data inputted yet. These rows also include two key fields called ' ...

The responsiveness of Slick Slider's breakpoints is malfunctioning

After implementing a slider using slick slider, I encountered an issue with the width when testing it online and in a normal HTML file. If anyone could assist me in resolving this issue, I would greatly appreciate it. Please inspect the code for both scen ...

Creating Filled DIVs using JavaScript

Although it may appear to be a common inquiry, my specific needs have not been addressed in any of the Stack threads I've come across. I am dealing with a series of nested DIV statements, as demonstrated here (not all CSS included). I am looking to ...

How to align items at the center in material-ui styling

I have a row of cards inside a container that I want to align in the center with equal spacing around them. I am using the material-ui UI library for the layout. Despite adding the justifyContent: center property, the cards are not evenly spaced. This is ...

How can Selenium click on an <a> element using By.LinkText and bypass any line breaks within the link text?

One a element contains text with \r\n within it. The HTML code is shown below: <a href="/Profile/ProfileView?isSuccessScreen=1&amp;URLID=x/ayvqzf7zojzzqiauihka" class="list green profile "> <img src="/content/css/theme/images/pro ...

Utilizing Sage 9 to Customize Woocommerce Templates

I am attempting to update Woocommerce template files using the latest Wordpress Sage. However, I am facing an issue where the new version of Sage with blade extension does not recognize the old Woocommerce template files. In the past, I would simply copy ...