Enabling the autowidth label expands the width of the td element

I am facing an issue where a label inside a table td grows in only one line when its width is greater than the td width. This results in the td expanding and not showing all the text. I would like the label to break into a new line when its width exceeds that of its container.

css
.pdata {
font-size: 10px;
}

<table valign="top" cellspacing="0" cellpadding="0" border="0" height="150">
    <tbody>
        <tr valign="top">
            <td class="profile-company-text">

                <label class="pdata" ><label class="bold" style="width: 140px; display: inline-block">Email: </label><label data-bind="text: Email"></label>
                    <br>
                </label>

                </span>
            </td>
        </tr>
    </tbody>
</table>

Answer №1

It seems like your browser is automatically adjusting the table size to fit your content. To set a maximum width for the table column with the label, you can use the CSS max-width attribute.

Unfortunately, it's hard to give a definitive answer to your question for a few reasons.

In the provided example, the label "Email" is unlikely to wrap because it's a single word without any breakable points. To clarify, you should offer more details such as a visual representation of the desired result and a code snippet that replicates the issue.

Furthermore, there are some structural issues in the markup. If you're using a generator, ensure it's set up correctly. Here are some problems I noticed:

  1. Nesting labels is incorrect. Labels should only contain non-labelable content.
  2. There is a closing span tag without an opening span.

Lastly, consider following these best practices for cleaner, more semantic, and maintainable code:

  1. Avoid using inline styles; use classes in the markup and external stylesheets or a style block instead.
  2. Instead of cellspacing, cellpadding, etc. attributes on tables, use CSS attributes.
  3. If a label is not linked to an input element, consider using a different element like p for text blocks.

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

I need help with customizing the progress bar in HTML and CSS

How can I create a progress bar like the one shown below: https://i.sstatic.net/BFv87.png .detail-load { height: 42px; border: 1px solid #A2B2C5; padding: 1px; border-radius: 10px; } .detail-load > .detail-loading { ...

Ways to create a self-contained video viewer

Is it possible to create a self-contained video player similar to jwplayer or the YouTube video player using just HTML, CSS, and JavaScript? I know that I can build a video player by utilizing the video tag along with some custom javascript and css, but ho ...

Tips on completing landing page animations and displaying the main page of a website by utilizing React JavaScript

https://i.stack.imgur.com/M4VgY.pngIs there a way to stop the landing page animation after 2-3 seconds and show the main page instead? Can I achieve this by using setTimeOut function in JavaScript? [ export default Loader; ...

Enhance your form input-group in Bootstrap-4 by adding a stylish border and background-color through validation

I'm working on a form using Bootstrap 4 and I need to display validation errors. Specifically, I want the text field with an input-group for the password to have the same styling as the Username field when there is an error (i.e., red border and backg ...

Adjusting the cell size to align with the height of another cell in the same row

Within a table row, I have two cells that contain divs and the height varies due to changing content. Is there a way for one cell to take up 100% height to match the other cell? You can see an example here. The goal is for the second cell and its div to ...

Internet Explorer does not support the use of a:focus

Unfortunately, the issue with a:focus not working in IE is still unresolved. I have been searching for a solution, but have not been able to find one yet. <div class="city-selection"> <ul> ...

Various web browsers (display: -webkit-inline-box;)

Recently, I encountered an issue with my CSS code: .tudo ul { width: 100%; margin: 0px; display: -webkit-inline-box; } Surprisingly, Mozilla Firefox does not recognize the following line: display: -webkit-inline-box; Is it possible to set d ...

Prevent page from reloading when Image Button is clicked

I attempted the following code: <asp:ImageButton ID="imgDropArrow" class="cssDropArrow" ImageUrl="~/Styles/Down.gif" OnClick="ImageDropArrow_Click" runat="server"/> Whenever I click on this image button, the page refreshes. What I'm looking ...

What are the steps to ensure the equalizer start button functions properly?

I have created an application that mimics the functionality of an equalizer by displaying changes in audio frequencies. https://i.sstatic.net/W7Fzi.png Issues with animation arise when you click the "Start" button again. The animation resets and begins ...

The div is not completely encased by the fieldset

I have utilized fieldset to generate a titled border around a div. Here is the code snippet: <div class="form-group col-xs-12"> <fieldset class="field_set col-xs-12"> <legend style="font-weight:bold;font-size:20px"> ...

The on-screen keyboard using JQuery and CSS is not working properly on an HTML redesign

UPDATE - Check out the modified version here: https://codepen.io/anon/pen/wZQjQy Here is the original for reference: https://codepen.io/anon/pen/YMRLBN (had to utilize CodePen, as simply adding a snippet here doesn't link the CSS) I essentially copie ...

Learn how to showcase the value of the selected radio button in AngularJS

To show the chosen radio button in the response div, make sure to hide the div if no option is selected. Check out the code below: <body ng-app="QuestionDisplayModule"> <form> <div ng-controller="QuestionDisplayController" ...

Is there a way for me to manually designate certain domains with the rel="follow" attribute while assigning all other external links with the rel="nofollow" attribute?

I'm working on developing a community platform similar to a social network. I've implemented a code that automatically makes all external links nofollow. However, I would like to create a feature that allows me to remove the nofollow attribute f ...

What is the best method for eliminating underscores from text that is hyperlinked in a locally hosted HTML file?

I recently encountered an issue with my HTML file where the text "Indian" became underlined after saving the file. Here is the code snippet: <a href="file:///G:\work files\project\indian.html" target="_blank"> <div class="button ...

Incorporating HTML5 audio elements in JavaScript

I am working on a project where I need to create a grid of 16 audio files with separate links for each in HTML, CSS and JavaScript. Each box in the grid should link to a different audio file. My initial thought was to use a table to achieve this, so I cre ...

Troubleshooting: The Google Analytics Universal Event Tracking Code is not functioning as

I am having trouble tracking clicks on an image that links to another site in a HTML widget on my website’s sidebar. I have implemented Google Analytics code, but for some reason, the clicks are not showing up in the "Events" tab of my analytics dashboar ...

Tips for creating a scrollable sidebar while ensuring that the deeply nested child pop-up element does not adhere to the scrollable properties

In my project, I am using Vue 3 along with Tailwind CSS and Headless UI. The challenge I am facing is making the sidebar navigation scrollable while ensuring that the pop-up menu appears outside the sidebar. As the number of menu items in the sidebar will ...

Changing the Color Scheme of Twitter BootstrapRevamping the Color Palette

I am interested in updating the color scheme of a website that I modeled after this example: http://getbootstrap.com/examples/navbar/ So far, I have successfully changed the background color of the entire page using: body{background-color:#XXXXXX} Howev ...

Position your Logo to the left, align the Menu in the center, and place top links on the right using Bootstrap

I am currently struggling to create two rows with the logo aligned to the left, 'Home' and 'User' menu links at the top right corner, and a second row displaying 'Link1', 'Link2', 'Link3' menus centered. Th ...

Dynamic stacking of buttons in response to user navigation choices

Is it possible to create a navigation bar with 5 buttons using CSS and JS? Here is what I am looking to achieve: Display 5 nav/button options When a user clicks on a button, the other buttons should transition or hide, leaving only the selected button vi ...