0

I am using br tag to create a line break for my web page faq.
Though the results are accurate, is there any alternative for using linebreak
via css to create responsive based web page.
By googling I found the pseudo element. But I didnt get a proper image of it.

.faqfirstsec {
  margin: 0 0 0 70px;
  background: lightgrey;
  height: 100%;
}

font.faqtitle {
  font-weight: bold;
}

font.faqques {
  color: red;
}
<div class="faqfirstsec">
  <font class="faqtitle" weight="bold">TITLE</font><br><br>
  <br>
  <br>
  <br>
  <br>
  <br>
  <br>
  <br>

  <font class="faqques">QUESTION 1</font><br><br>
  <font class="faqans">ANSWER 1<br> ANSWER 1。</font><br><br><br><br><br>
  <font class="faqques">QUESTION 2</font><br> ANSWER 2<br><br><br><br>
  <font class="faqques">QUESTION 3</font><br> ANSWER 3<br><br>
</div>


I want to create some spaces among question 1 , 2 and so on.
I have used font class tag , but cannot use Margin .
Should I go for DIV instead of FONT ?

Chris Li
  • 2,628
  • 1
  • 8
  • 23
Anuj
  • 170
  • 11

3 Answers3

0

.faqfirstsec {
 margin: 0 0 0 70px;
 background: lightgrey;
  height : 100%;           /* this doesn't do much unless parent has a height */
}

.faqtitle {
 font-weight: bold;
  margin-bottom: 10px;
}

.faqques {
 color: red;
  margin-bottom: 15px;
}

.faqans {
  margin-bottom: 35px;
}
<div class="faqfirstsec">
  <div class="faqtitle">TITLE</div>

  <div class ="faqques">QUESTION 1</div>
  <div class="faqans">ANSWER 1<br>ANSWER 1</div>
  
  <div class ="faqques">QUESTION 2</div>
  <div class="faqans">ANSWER 2<br>ANSWER 2</div>
  
  <div class ="faqques">QUESTION 3</div>
  <div class="faqans">ANSWER 3<br>ANSWER 3</div>
</div>
Asons
  • 84,923
  • 12
  • 110
  • 165
Anuj
  • 170
  • 11
0

If you wrap your desired text (contains <br/>) in an element with white-space: pre all \ns will render as <br/>.

Also you can use <pre></pre> tag which wrapped your text.

But about HTML, You can do it like this:

 <span>hello</span><span data-x>BR!</span>

And its css (excuse me for no snippet or fiddle, I'm typing with my mobile phone and I haven't access to the code tools of stackoverflow's editor):

[data-x]:before{
    content: "\A";
    white-space: pre;
 }

Added part

Now, for your case, only try this:

.faqans:before{
    content:"\A\A\A";/*per be, one \A*/
    white-space:pre;
}
Hassan Sadeghi
  • 1,316
  • 2
  • 8
  • 14
-1

Use

margin-bottom: 100px;
display: block;

for the font tag.

font tag is an inline element and now it is deprecated. Instead of font tag use Div or span.

Anji
  • 689
  • 1
  • 5
  • 24
  • @LGSon, Both are the same answers. Why did you added downvote to my answer. – Anji Sep 25 '18 at 04:34
  • Because you suggest how to use `font` (displayed as block though). `font` is deprecated and shouldn't be used, so an answer with it, is a bad answer. – Asons Sep 25 '18 at 04:35
  • I was mentioned that font tag was deprecated. – Anji Sep 25 '18 at 04:39
  • You still refer the given CSS for the font tag. Some users will just try the provided CSS, and as that (still) might work they might keep it and then it suddenly will not, so I suggest you rephrase the answer – Asons Sep 25 '18 at 04:41