How can I add text to a bar or table using CSS/HTML?

I am trying to create a design similar to this:

http://img291.imageshack.us/img291/5571/bartablestyling.png

Currently, I only have the top bar in place.

When I attempt to add text, it ends up below the profile picture. I want to avoid using float:left for positioning.

Is there a way to use a table to achieve this text layout and properly adjust the spacing indicated by the red arrow that I added?

Here is the code snippet I am working with:

<div style="background-image: url(images/notificationShelfBg4.png);
    background-repeat: repeat-x;
    background-position: bottom; width: auto;">

            <img src="<?php if(!empty($vP["photo_thumb"])) { echo "images/profileimages/".$vP["photo_thumb_small"]; }else{ echo "images/profileimages/noPhoto_thumb.jpg"; } ?>"  style=" border: 2px solid #CCC; margin-right: 5px; margin-left: 15px;  margin-bottom: 2px;">


    </span>
    </span>
    </a>

</div>

Answer №1

To achieve this layout, consider creating a table with 4 columns and 2 rows.

<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td>Logged in as:</td>
<td>Gender: Male</td>
<td>Field:1</td>
<td>Field:1</td>
</tr>
<tr>
<td>Andrew</td>
<td>Age: 22</td>
<td>Field:1</td>
<td>Field:1</td>
</tr>
</table>

You can adjust the width of the cells using CSS, such as setting td {width:200px;}. Another approach is to assign a class to each cell like

<td class="cell">Gender: Male</td>
and style it with CSS using .cell {width:200px;}.

If needed, you can also explore using floats and other tricks to achieve the desired outcome.

Answer №2

If you want to display your profile information in HTML, here's how you can do it:

<div class="profile">
    <img src="path/to/your/img.png" alt="Example's Avatar" />
    <p class="login-info">You are logged in as: <span class="username">Example User</span></p>
    <ul class="user-info">
        <li>Gender: Male</li>
        <li>Age: 24</li>
        <li>Member since: 24 Aug 2009</li>
        <li>Currently wearing: Pink T-Shirt</li>
        <li>Email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="402538212d302c25002538212d302c256e232f2d">[email protected]</a></li>
        <li>Another field: Value 1</li>
        <li>Drinking: Coffee</li>
        <li>Mug collection: 300</li>
        <li>Another field: Value 2</li>
    </ul>
</div>

This markup includes an image, login information, and various user details displayed in a structured format. By using specific classes for styling elements, we ensure the content is presented as intended.

.profile {
    padding: 20px;
    background: #333 url('path/to/gradient.png') repeat-x;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.6em;
    font-family: Arial, sans-serif;
    color: white;
    width: 960px;
}

.profile img {
    width: 80px;
    height: 80px;
    border: 1px solid #eee;
    display: block;
}

.profile .login-info, .profile .user-info li, ... 

Separating CSS from HTML allows for easier maintenance and customization. The styling rules define the layout and appearance of each element within the profile box, creating columns with specific widths and margins.

To see this in action, check out the live demo here: http://jsfiddle.net/stEkY/

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

Activate audio when the link is clicked

Recently, I created a compact web application and it's almost complete. However, there is one cool functionality that I am missing. My goal is to have a sound play when the user clicks a link, but after playing, I want the navigation to continue as us ...

There seems to be a column in the MySQL INSERT query that is unidentifiable and does not exist in the list of fields

id and cost are required as integers and cannot be left empty. I encountered the following error message: 'Error: ER_BAD_FIELD_ERROR: Unknown column 'undefined' in 'field list'' var sql = "INSERT INTO Paintings(` ...

Consistent sizing for Bootstrap thumbnail images

In my current project, I am implementing a Bootstrap thumbnail feature where each thumbnail consists of an image and a heading. However, a problem arose as the images do not have the same size, resulting in thumbnails with varying dimensions. To resolve th ...

Update the input tag's value dynamically using another input element without the need for jQuery

I am working with 2 input tags Title: <b-input style="width: 50%" v-model="value.title" class="input-element" placeholder="Title" v-on:click="greet" /> Id: <b-input id="id" style="width: 50%" ...

Ensure that all of the <li> elements within a <ul> container have equal widths

I've been grappling with this problem for the past day, and despite restarting from scratch multiple times, I can't seem to make a horizontal CSS flyout header function as intended. The dropdown section should expand to fit the content width (id ...

I am experiencing difficulties with my HTML and CSS code not functioning as I had initially intended

I've been dabbling in HTML and attempting to create my own website, but I'm encountering an issue with the positioning of my <table> tag. It keeps appearing at the bottom of the site, despite my CSS instructions to prevent it. The position ...

Is there an issue with the padding not functioning correctly on smaller and medium-sized devices when using Bootstrap

On my desktop, I added '50px' padding to the body of my page and it's working properly. However, on smaller and medium screens, it's not functioning correctly. I tried using Bootstrap @media CSS functionality, but it still doesn't ...

Do not open iframe links in a new window

Is it possible to manipulate the iframe so that links open inside the iframe window? I want the links clicked within the iframe to stay within the same window instead of opening in a new one. However, I have too many links to individually edit their code ...

Having trouble getting the form input max-width to work properly within a flex-box

My webpage features a header containing various icons, a title, and a search box that triggers an animation when the search button is clicked. While this setup works seamlessly on larger screens, I encounter issues on smaller screens. My goal is for the se ...

MySQL unable to access information entered into form

After creating a new log in / register template using CSS3 and HTML, I now have a more visually appealing form compared to the basic one I had before. To achieve this look, I referenced the following tutorial: http://www.script-tutorials.com/css 3-modal-po ...

Scrolling with JQuery Sortable will go up in the list, but it won't allow for

My current issue revolves around a problem in JSP, but for better understanding, I have replicated the issue using HTML. The main page involves using sortable to enable drag and drop rearrangement of elements (list items). However, the scrolling behavior i ...

Issues with the parallax zooming out effect

Delving into the world of parallax effects, I'm on a quest to achieve a captivating zoom-out effect while scrolling. However, I'm encountering an issue where the image shrinks beyond the browser width and the div's height. In the example pr ...

Updating the default color of selected text within a webpage's content

Is there a way to modify the default blue color that appears when content is selected on a webpage? I am wondering how to change this selection color to a custom color of choice. ...

Emptying the AnyChart (Javascript) container prior to generating new charts

I have been utilizing the anychart JavaScript library to generate a pie-chart from my data, which is dynamically pulled whenever a user modifies a dropdown selection. Below is the code snippet I am employing for this purpose: var stage = anychart.graph ...

Ensure that CSS is integrated correctly

I have a main Django template that incorporates another template for the navigation bar. I currently have separate CSS files for both the main page and the navbar. My query is: what is the correct method to include the CSS from the navbar in the main p ...

There are a few issues with certain Bootstrap elements such as the Navbar-collapse, p- classes, and small column images

I wanted to express my gratitude for all the incredible resources shared here. I have been working on sorting out some issues over the past few days. While Bootstrap seems to be functioning well in certain areas, it's not working as expected in oth ...

Optimal methods for organizing various perspectives on a one-page website

I am developing an application that incorporates AngularJS and Bootstrap. The current setup involves organizing various views using ng-show, allowing for view changes based on button interactions and the enablement/disabling of ng-show values. Within a si ...

Connecting HTML pages on two different drives on the same computer: Is it possible?

Is it possible to create hyperlinks between HTML pages located in two different folders on separate drives (for example, one in Drive:C and another in Drive:E) on the same computer? I can navigate up multiple directories and to different folders or subfol ...

In Pure JavaScript, an HTML element is added every time the click event is triggered

Hey everyone, I'm facing a small issue and I could use some help fixing it. I need to implement an onclick event that adds HTML code every time it's clicked. I am hesitant to use innerHTML due to its potential risks. Here is the code snippet: bu ...

What is the best method for retrieving text that does not contain tags (such as text

My challenge involves storing headings and paragraphs into separate arrays, but I am struggling with handling text between <br>. Below is my HTML code and Python snippet: <p><strong>W Ognisku</strong><br>W londyńskim Ognisku ...