Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5989133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:03:30+00:00 2026-05-22T23:03:30+00:00

I have an HTML page with some <code> segments, and I have given them

  • 0

I have an HTML page with some <code> segments, and I have given them these attributes in an external CSS folder:

code {

    background-color: f5f5ff;
    border-color : 7f7fbf;
    border-style : dashed;
    border-width : 1px;
    font-family  : courier new;
    margin-left  : 128px;
    padding      : 14px;
}

Whenever I put a <br/> in my code segments, the code seems to jump to the left, ignoring the margin, and the padding covers the last line, like it was a whole new <code> segment placed directly below it, down to about where the padding would end, and without a left margin.

How do I make a <code> segment with line breaks that displays all the code in a single ‘box’, line breaks and all, until the end of the <code> segment, like it is being displayed in the <code> segments in the preview of my post right now?

Here’s an example of one of my <code> blocks/segments:

import math<br/>
def areaCircle(r)<br/>
return (math.pi * r) ^ 2

Unfortunately, I cannot provide a picture because I am a very new user.

I have tested this in both Chrome and FireFox; the problem is exactly the same in both browsers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:03:31+00:00Added an answer on May 22, 2026 at 11:03 pm

    You are better off not adding <br /> and using white-space: pre and display: block on the code element.

    code {
       display: block;
       white-space: pre;
    }
    

    jsFiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Setup: I have an HTML page with a fieldset element. The background color of
I have a basic HTML page with some JavaScript code on it, and when
Assume that I have some HTML page, and a corresponding CSS file. I'd like
I have some JavaScript code that dynamically injects an iframe in a given HTML
I have a HTML page with which I want to do some client side
I have a HTML page that contains a flash file and some a JavaScript
I have an HTML page (say welcome.html) which contains an iframe to a page
I have a HTML page that scrolls up and down (not a lot, but
We have an HTML page which displays a bunch of pretty bars using divs
Suppose I have one html page with frames. The left frame is simply a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.