What is preventing CSS from adding a line break for the input element?

Here's a clever way to insert a new line before every span tag.

span {
    display: inline;
}
span:before {
    content: "\a ";
    white-space: pre;
}
<p>
  First line.<span>Next line.</span> <span>Next line.</span>
</p>

Following the same pattern, I would like to add a new line at the end of each input element. Why doesn't it work for the input element?

input{
    display:inline;
}
input::after{  
    content:"\a ";
    white-space:pre;
}

  
content:<input id="1th" type="text" >
content:<input id="3th" type="text" >
content:<input id="4th" type="text" >

Answer №1

You have explicitly defined the display property of your input as inline.

An inline element does not begin on a new line.


Resolution:

A block-level element always starts on a new line.

Modify the display property value of the input selector to block.

input{
    display:block;
}
input::after{  
    content:"\a ";
    white-space:pre;
}
content:<input id="1th" type="text" >
content:<input id="3th" type="text" >
content:<input id="4th" type="text" >


This entire process is superfluous, since every HTML element is categorized as either a block element or an inline element. It appears that the input element is actually a block element, rendering this CSS declaration unnecessary.

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

Tips on Including Static Header and Footer in Multiple HTML Pages

What is the best way to reuse a header and footer on multiple HTML pages without repeating code? I have 5 HTML pages that all need to include the same header and footer elements. How can I efficiently reuse these components across all pages? ...

How can you adjust the width of the Material UI Select component?

Trying to customize the width of the Material UI Select component can be a bit tricky. To set the desired width, you need to assign a specific class to the FormControl component. This class, such as mw-120, should define the minimum width as 120px in your ...

Adjusting background-position-x while scrolling

I came across Ian Lunn's Parallax tutorial and found it really interesting. The tutorial can be accessed at . My goal is to enhance the effect by not only changing the y-position of the background but also adding horizontal movement based on scroll in ...

Place one flex item in the center and align another item to the bottom

I am attempting to center one flex item both vertically and horizontally. At the same time, I want some text to remain fixed at the bottom of the flex container. When I use margin-top:auto on the text, it just moves the inner box to the top. Any suggesti ...

What could possibly be the reason behind jQuery's inability to function properly with HTML content that was dynamically added to the page through an Ajax

The following code snippet is responsible for submitting a form using Ajax and displaying the result from the addNewUser.php script in a popup window. //trigger the signup submit button $('#button_signup_submit').click(function() { document ...

The CSS box-shadow property failed to render properly on Internet Explorer and Safari browsers

#keyboard { position: fixed; background: #eee; display: none; border: 1px solid #ccc; border-radius:7px; width: 950px; height: 300px; padding: 5px; cursor: move; background-image:url('BackgroundImage.jpg'); box-shadow: -5px -5px 5px 5px #888; -m ...

Utilize background-size:cover and incorporate text in a horizontally scrolling webpage

Struggling to create a minimalist HTML layout with a horizontal scrollbar, featuring a large image on the left and a lengthy text with columns on the right? I suspect the issue lies in the implementation of position:relative with float, as well as position ...

Steps for resetting the ng-multiselect-dropdown

Is it necessary to wrap the ng-multiselect-dropdown in a form in order to reset it? code - app.component.html <div> <p id = "node">Select a Root API Object - </p> <p style="width:50%"> <ng-multiselect-dropdown [placeho ...

I'm struggling to figure out why the CSS isn't working properly

i found this markup like shown here i am curious why it appears that lines 12 & 13 .notes:link span, .notes:visited span { ... seems to be functioning .comments span, background-position: -16px -16px; } .permalink:link span, .permalink:visited sp ...

Selenium Webdriver is having trouble locating an element within an xblock

As a beginner in Python, Selenium, and coding in general, I'm not sure if my question even makes sense. My current project involves automating the task of saving edX course webpages as HTML. I am using the latest iPython and Webdriver for this purpos ...

Take a break in between keyframe animations

I have a basic animation set up with keyframes. @-webkit-keyframes rotation { 0% { -webkit-transform: rotate(10deg); } 25% { -webkit-transform: rotate(5deg); } 50% { -webkit-transform: rotate(10deg); } 75% { -webkit-transform: ...

I'm having trouble getting Jquery's insertAfter() function to function properly

After creating a parent div and using jQuery's insertAfter() method to insert additional divs, an unexpected issue arises. The first record goes to the bottom, while subsequent records are inserted above it. Below is the function in question: functi ...

Error encountered in ASP.NET Core MVC due to dependency inversion with CRUD operations

Today I delved into dependency inversion. Prior to implementing this concept, my CRUD system was functioning well, but now I am encountering some errors. The error message says "Cannot implicitly convert type int to ContractLayer.UsersDto." In the image pr ...

Modify a website link using Javascript by detecting two separate button clicks

I am seeking a way to dynamically change the src attribute of different images on a house depending on which button has been clicked. There are two groups of buttons: The types of house parts, such as windows, doors, garage, soffits, and gutters. The col ...

Ways to combine text styling with images, stroke effects, and shadows all at once

I am looking to enhance my text with a background image, a text-stroke, and a text-shadow. The issue I am facing is that the text-shadow appears on top of the background image. Does anyone have a solution for placing the shadow behind the image? If you te ...

Center a specific item by aligning it with flex

I'm struggling to achieve a simple layout using flexbox, and I can't figure out how to do it. My objective is to have 3 divs aligned in a row, with the middle div (containing "short") centered. A visual representation would make it clearer: The ...

Accordion menu designed exclusively with JavaScript

Implementation of required menu structure: Main Menu Submenu Contacts News Photo Submenu Submenu Submenu Main Menu Main Menu Main Menu When clicking on the "Main Menu" button, a list of "Submenu" elements opens. Clicking on the "Submenu" button ope ...

Troubleshooting problem with printing iframes on Firefox

When attempting to print an iframe with a large amount of data using the code below, I'm encountering an issue in Firefox where only the first page is printed. The rest of the pages are not being included in the printout. window.frames[frameID]. ...

React rendering: Injects an equals sign and quotation marks into the async attribute of <script> tag

I recently developed a basic web application using Next.js and React. One of the functional components (referred to as a "page" in Next.js) includes a script tag like this: <script async src="https://example.com/file.js"></script> However, upo ...

Best practices for arranging several divs with CSS

I am in the process of creating a main header for several web pages I'm working on. The layout I have in mind includes an image, centered text below the image (all to the left of the main header), a main header that I want to be in the center of the p ...