[css] CSS force new line

I have something like this:

<li>Post by <a>Author</a></li>

And I want to display the link in a new line, like this

Post by
Author

How can I achieve this? Clear:left doesn't work.

This question is related to css css-float newline

The answer is


Use the display property

a{
    display: block;
}

This will make the link to display in new line

If you want to remove list styling, use

li{
    list-style: none;
}

Use <br /> OR <br> -

<li>Post by<br /><a>Author</a></li>

OR

<li>Post by<br><a>Author</a></li>

or

make the a element display:block;

<li>Post by <a style="display:block;">Author</a></li>

Try


or you can use:

a {
    display: inline-block;
  }

How about with a :before pseudoelement:

a:before {
  content: '\a';
  white-space: pre;
}

Examples related to css

need to add a class to an element Using Lato fonts in my css (@font-face) Please help me convert this script to a simple image slider Why there is this "clear" class before footer? How to set width of mat-table column in angular? Center content vertically on Vuetify bootstrap 4 file input doesn't show the file name Bootstrap 4: responsive sidebar menu to top navbar Stylesheet not loaded because of MIME-type Force flex item to span full row width

Examples related to css-float

Bootstrap - floating navbar button right Bootstrap change div order with pull-right, pull-left on 3 columns Bootstrap 3 Multi-column within a single ul not floating properly CSS float right not working correctly Floating Div Over An Image CSS force new line Why doesn't the height of a container element increase if it contains floated elements? Advantages of using display:inline-block vs float:left in CSS Floating divs in Bootstrap layout What does the CSS rule "clear: both" do?

Examples related to newline

How can I insert a line break into a <Text> component in React Native? Print "\n" or newline characters as part of the output on terminal Using tr to replace newline with space How to write one new line in Bitbucket markdown? Line break in SSRS expression How to insert a new line in Linux shell script? Replace CRLF using powershell How to write new line character to a file in Java What is the newline character in the C language: \r or \n? How to print values separated by spaces instead of new lines in Python 2.7