Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. div

div

Scheduled Pinned Locked Moved Web Development
csstutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rose196
    wrote on last edited by
    #1

    Hai I am using div.Inside the div i wrote some content. for that i set width auto, browser take it with as 100%.why it is taking like that. i want the width is equal to my content. example

    Hai

    in css div { width:auto; } If i gave like this it should measure only the word know.but it measure the whole line. Can give the solution . why it is happen like this. Thanks in advance

    P 1 Reply Last reply
    0
    • R rose196

      Hai I am using div.Inside the div i wrote some content. for that i set width auto, browser take it with as 100%.why it is taking like that. i want the width is equal to my content. example

      Hai

      in css div { width:auto; } If i gave like this it should measure only the word know.but it measure the whole line. Can give the solution . why it is happen like this. Thanks in advance

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      You are using a block-level element (div) which will always attempt to take up "the entire line" as opposed to flow-level elements (u, img, span etc.) which take up just the space of their contents. You should not be setting width: auto often as it is the default. Only if you are overriding inherited properties will you set it. I don't know what you are trying to do but this may be more appropriate:

      <span>
      <u>Hai</u>
      </span>

      span is a flow-level generic element while div is a block-level generic element.

      cheers, Paul M. Watson.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups