Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make new line without using <br> in HTML

Tags:

I want to make each one of these element is different line, without using <br /> in HTML, <h1> is block element but I have to fix its width. How can I make anchors come under <h1> not beside?

<h1 id="viewerTitle">Header </h1>
<a href="#" class="view-options">View options</a>
<a href="#" class="view-options">View options</a>

Here's an example: http://jsfiddle.net/mmhhd/

like image 641
palAlaa Avatar asked Feb 03 '12 19:02

palAlaa


People also ask

What can I use instead of BR tag in HTML?

Instead of using the <br> tag, you should use a semantic HTML element and the CSS margin or padding properties if necessary.

How do I add a new line in HTML?

Note: Use the <br> tag to enter line breaks, not to add space between paragraphs.

Do you need </ br in HTML?

Learn HTML In HTML, the <br> tag is used for line break. It is an empty tag i.e. no need to add an end tag. Writing <br> tag is perfectly fine.


2 Answers

Start by removing float: left from h1.

Then add the rule:

a.view-options {
    display: block;
}
like image 145
Kylos Avatar answered Oct 05 '22 05:10

Kylos


Alternative way:

Remove float:left; in h1 and display: inline-block; in a.view-options

Then add

h1:after, a:after {
    content:"\a";
    white-space: pre;
}

See http://jsfiddle.net/8my6q/

like image 42
Rannnn Avatar answered Oct 05 '22 05:10

Rannnn