Arranging 2 divs side by side

As a beginner, I'm struggling to find the answer because I have no idea what search terms to use.

Now, I have a form

        <form action="#" method="POST">
            <div id="labels">
    <label>CMS System</label><p>
    <label>Responsive Design</label><p>
    <label>Google Package+</label><p>
    <label>Google Ranking</label><p>
    <label>Slider/Slideshow</label><p>
    <label>Social Media</label><p>

<div id="input">
<input type="text" name="page" value="1"><p>
Yes<input type="radio" name="cms" id="cmsyes" value="yes"/> No<input type="radio" name="cms" value="no" id="cmsno" checked/><p />
Yes<input type="radio" name="Responsive" value="yes"/> No<input type="radio" name="Responsive" value="no" checked/><p />
Yes<input type="radio" name="Googlepkg" value="yes"/> No<input type="radio" name="Googlepkg" value="no" checked/><p />
Yes<input type="radio" name="Googlerank" value="yes"/> No<input type="radio" name="Googlerank" value="no" checked/><p />
Yes<input type="radio" name="slideshow" value="yes"  /> No<input type="radio" name="slideshow" value="no" checked/><p />
Yes<input type="radio" name="socials" value="yes" id="socialyes" /> No<input type="radio" name="socials" value="no" id="socialno" checked/><p />
            </div>
    </form>

I would like

#input {
      move next to #labels instead of being below it

}

I tried using margin: -xxxpx; but I understand that is not the correct way to achieve this.

JSFiddle http://jsfiddle.net/tAVGC/

Answer №1

http://example.com/CAT65/

#categories { float: right; margin-left: 12px; }

Don't forget to close your tags properly.

On the topic of styling with ids, I suggest using classes instead. Check out this blog post by Sarah Smith for some great insights and additional resources.

Answer №2

Here are a couple of things to note:

Make sure your <div id="labels" > has a closing tag like </div>.

Remember that <p> tags require both an opening and closing tag, such as <p></p>

Consistency is key - ensure every element receives a <p> tag if you want them aligned properly. Consider using the following markup for side-by-side display in HTML:

<label>CMS System</label><input type="radio" name="cms" />

If you prefer separate <div> containers, you can try this approach:

http://jsfiddle.net/sk6gz/1/

There may be a discrepancy between the elements. To achieve the desired result, consider adding an extra <p> tag in either the first or second <div> container.

Answer №3

Are you attempting to create your own CMS system?

If you want to master CSS styling for positioning elements, I recommend researching the css box model. This will provide valuable information on how to arrange elements horizontally.

As for your current issue, it seems like you are aiming for a layout similar to this example: JSFiddle

To solve your problem, make sure to group each label with its corresponding control (radio button) in the markup:

<label>CMS System</label>
Yes<input type="radio" name="cms" id="cmsja" value="yes"/> 
No<input type="radio" name="cms" value="no" id="cmsno" checked="checked" />
<br/>

I included a <br/> element for quick spacing, but utilizing the box model will offer more precise positioning options.

Additionally, exploring topics like html forms may be beneficial for your project.

Consider starting with smaller projects as a beginner before tackling a full-fledged CMS.

Answer №4

When it comes to styling form elements, this approach can be quite effective:

HTML:

<label>Content Management System</label><input type="radio" name="cms" />
<label>Your thoughts</label><input type="text" name="thoughts" />

CSS:

label, input[type=text] { display:inline-block; text-align: right; }
label { width: 30%; margin-right: 2%; }
input, input[type=text] { width: 60%; }

The radio buttons don't require a set width, but I included the text input to demonstrate how you could further enhance the styling of forms.

For a visual example, check out this link: http://jsfiddle.net/harveyramer/E7kSt/

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

Struggling to make the grunt.js task for postcss with autoprefixer function properly

I am currently facing issues with using postcss in conjunction with autoprefixer-core. Even though the css is being generated correctly, autoprefixer doesn't seem to be applying any prefixes. I have already installed postcss and autoprefixer via NPM ...

Creating a bootstrap form field that spans 100% in width:

I am encountering an issue with two column divs in a row, each containing two text fields. When resizing on mobile, the width of the textbox is not expanding to 100% and looks unattractive. Below is my Bootstrap code, but strangely, the width looks fine f ...

Convert several XML nodes to display in an HTML format

I am currently facing an issue where I am trying to display all the nodes of a specific tag in XML. Although it does filter the data correctly, only one node is showing up. Is there anyone who can assist me with this problem? Below is the XML content: < ...

List with Columns for Organization

I am not seeking advice on how to use columns in lists, but rather on aligning the columns on my website. Below is the code I have: <ol class="threecolumns"> <li>Item 1</li> <li>Item 2</li> <li>Item 3< ...

Achieving Text Wrapping Around Unconventional Shapes Using CSS

I'm currently facing a challenge in getting text to wrap around an irregular shape on a web page. Despite numerous attempts, I have yet to find a solution that meets my requirements. Attached is an image illustrating the layout I am aiming for. The ...

Alignment issue with reCAPTCHA box detected

Why can't I seem to align the reCAPTCHA form properly on my registration page? Even though the div it is within has its text-align property set to center, the form still displays on the left side of the page: However, when I use JavaScript to chang ...

The many potentials of looping through Sass maps

My sass map contains a variety of color shades, and the full code can be found on Codepen: $pbcolors: ( pbcyan : ( 50: #E5F5FC, 100: #CCEBF9, 200: #99D7F2, 300: #66C3EC, 400: #33AFE5, 500: #009DBF, 600: #008CAB, 700: #007C98, 800: #006D85, 900: #005D72 ...

Stop the MatSort feature from activating when the space key is pressed in Angular Material

I am currently using angular material tables and have implemented filters for each column. The filter inputs are located in the row header of each column, which is working fine. However, I am facing an issue where whenever I type and press the space key, ...

What is the reason behind this HTML/CSS/jQuery code functioning exclusively in CodePen?

I have encountered an issue where this code functions properly in JSFiddle, but not when run locally in Chrome or Firefox. I suspect there may be an error in how the CSS or JavaScript files are being linked. In the Firefox console, I am receiving an error ...

Executing functionality based on changes in Angular bindings

I am working on securing user passwords in my HTML form. Currently, the password field is stored in localstorage like this: In JS: $scope.localStorage = localStorage; And then in HTML: <input id="pass" type="password" ng-model="localStorage.pass" re ...

Navigating through website links while working locally on a localhost server can

After exclusively working on live domains or subdomains in the past, I recently experienced the benefits of working on localhost. Utilizing a Wamp server on my Windows machine, I store my project in C:/wamp64/www/[project_name]. I have always used relativ ...

I'm having trouble removing records from MySql

I am facing an issue with two tables in my database. Table a is referencing table b, or so I believe. Whenever I attempt to delete the entire package using the following query: $query="DELETE a, b FROM classified as a, $sql_table as b WHERE a.ad_id = &ap ...

What is the best way to apply a CSS class to my anchor tag using JavaScript?

I have a good grasp of using JavaScript to insert an anchor element into my webpage. For instance, var userName_a = document.createElement('a'); However, I am interested in adding a style name to that same element as well. I attempted the follo ...

When an accordion is clicked, the content is dynamically loaded within the accordion on the page using PHP, jQuery, and AJAX

To optimize the loading speed of my information-filled page connected to two databases using php, javascript, jquery, I'm looking for a way to make the upload process faster. Currently, some data is displayed immediately while other details are hidden ...

Angular's responsiveness is enhanced by CSS Grid technology

I am attempting to integrate a CSS grid template that should function in the following manner: Columns with equal width 1st and 3rd rows - 2 columns 2nd row - 3 columns Order = [{ details:[ { key: '1', label ...

Can CSS be used to generate these shadows?

Check out this image I made showcasing a board with an elongated shadow cast behind it. The intention is to emulate the look of the board leaning against a wall, resulting in a triangular shadow on either side. I'm curious if it's achievable to ...

QuickSearch displayed at the center with a floating left alignment

I have been trying to center a QuickSearch div with multiple Q & A sections, but I am having no success. The div is floated to the left and has a background image. HTML <div class="l-row"> <div class="QuickSearch"> <div class="loop"& ...

Disappearance of the second level in a CSS dropdown menu

I am currently working on creating a dropdown menu using only CSS. Check out this example I'm using: http://jsfiddle.net/DEK8q/8/ My next step is to center the menu, so I added position-relative like this: #nav-container { position: rela ...

The specified font is not loading despite being correctly defined

I have a font stored locally in resources/fonts/ and I'm correctly linking to it, but for some reason, it's not loading. Here is the <style> section in my html: <style> @font-face{ font-family:"franklin_gothic_condensed"; ...

The Google API is experiencing issues when using input that has been added on

Situation: In my attempt to integrate a Google address search feature into an online shopping website, I encountered a challenge. I don't have direct access to the website's HTML code, but I can insert code snippets in the header, footer, and in ...